[PATCH 1 of 7] drafts: database change

Jan Heylen heyleke at gmail.com
Tue Apr 14 12:03:39 EDT 2015


# HG changeset patch
# User Jan Heylen <heyleke at gmail.com>
# Date 1427461084 -3600
#      Fri Mar 27 13:58:04 2015 +0100
# Node ID cb41b8211291b55bcd7c77919f714791927b8045
# Parent  00be591b077cab2eb900bd26628787fa40dc1674
drafts: database change

diff -r 00be591b077c -r cb41b8211291 kallithea/__init__.py
--- a/kallithea/__init__.py	Mon Apr 13 16:04:29 2015 +0200
+++ b/kallithea/__init__.py	Fri Mar 27 13:58:04 2015 +0100
@@ -76,7 +76,7 @@
     pass
 
 __version__ = ('.'.join((str(each) for each in VERSION[:3])))
-__dbversion__ = 31  # defines current db version for migrations
+__dbversion__ = 32  # defines current db version for migrations
 __platform__ = platform.system()
 __license__ = 'GPLv3'
 __py_version__ = sys.version_info
diff -r 00be591b077c -r cb41b8211291 kallithea/lib/dbmigrate/versions/032_version_2_2_3.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/kallithea/lib/dbmigrate/versions/032_version_2_2_3.py	Fri Mar 27 13:58:04 2015 +0100
@@ -0,0 +1,32 @@
+import logging
+
+from sqlalchemy import *
+
+from kallithea.lib.dbmigrate.migrate import *
+from kallithea.lib.dbmigrate.migrate.changeset import *
+
+log = logging.getLogger(__name__)
+
+
+def upgrade(migrate_engine):
+    """ Upgrade operations go here.
+    Don't create your own engine; bind migrate_engine to your metadata
+    """
+
+    #==========================================================================
+    # Upgrade of `changeset_comments` table
+    #==========================================================================
+    tblname = 'changeset_comments'
+    tbl = Table(tblname, MetaData(bind=migrate_engine), autoload=True,
+                    autoload_with=migrate_engine)
+
+    #ADD draft column
+    draft = Column("draft", Boolean, default=False)
+    draft.create(tbl, populate_default=False)
+    draft.alter(nullable=False)
+    return
+
+
+def downgrade(migrate_engine):
+    meta = MetaData()
+    meta.bind = migrate_engine
diff -r 00be591b077c -r cb41b8211291 kallithea/model/comment.py
--- a/kallithea/model/comment.py	Mon Apr 13 16:04:29 2015 +0200
+++ b/kallithea/model/comment.py	Fri Mar 27 13:58:04 2015 +0100
@@ -194,6 +194,7 @@
         comment.text = text
         comment.f_path = f_path
         comment.line_no = line_no
+        comment.draft = False
 
         if revision:
             comment.revision = revision
diff -r 00be591b077c -r cb41b8211291 kallithea/model/db.py
--- a/kallithea/model/db.py	Mon Apr 13 16:04:29 2015 +0200
+++ b/kallithea/model/db.py	Fri Mar 27 13:58:04 2015 +0100
@@ -2154,6 +2154,7 @@
     text = Column('text', UnicodeText(25000), nullable=False)
     created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
     modified_at = Column('modified_at', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
+    draft = Column('draft', Boolean, default=False)
 
     author = relationship('User')
     repo = relationship('Repository')


More information about the kallithea-general mailing list