[PATCH v2] drafts: database change

Jan Heylen heyleke at gmail.com
Mon Apr 27 14:23:42 EDT 2015


# HG changeset patch
# User Jan Heylen <heyleke at gmail.com>
# Date 1430111420 -7200
#      Mon Apr 27 07:10:20 2015 +0200
# Node ID 86489d15913a078bb9fbb89aa5a425bb9165d349
# Parent  30419d563fb96eeb58cae4dd65781af71b36b264
drafts: database change

server_default allows downgrades without breaking the database

diff -r 30419d563fb9 -r 86489d15913a kallithea/__init__.py
--- a/kallithea/__init__.py	Fri Apr 24 02:03:50 2015 +0200
+++ b/kallithea/__init__.py	Mon Apr 27 07:10:20 2015 +0200
@@ -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 30419d563fb9 -r 86489d15913a 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	Mon Apr 27 07:10:20 2015 +0200
@@ -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, server_default='0')
+    draft.create(tbl, populate_default=True)
+    draft.alter(nullable=False)
+    return
+
+
+def downgrade(migrate_engine):
+    meta = MetaData()
+    meta.bind = migrate_engine
diff -r 30419d563fb9 -r 86489d15913a kallithea/model/comment.py
--- a/kallithea/model/comment.py	Fri Apr 24 02:03:50 2015 +0200
+++ b/kallithea/model/comment.py	Mon Apr 27 07:10:20 2015 +0200
@@ -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 30419d563fb9 -r 86489d15913a kallithea/model/db.py
--- a/kallithea/model/db.py	Fri Apr 24 02:03:50 2015 +0200
+++ b/kallithea/model/db.py	Mon Apr 27 07:10:20 2015 +0200
@@ -2155,6 +2155,7 @@
     text = Column(UnicodeText(25000), nullable=False)
     created_on = Column(DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
     modified_at = Column(DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
+    draft = Column(Boolean, default=False)
 
     author = relationship('User')
     repo = relationship('Repository')


More information about the kallithea-general mailing list