On 04/14/2015 06:03 PM, Jan Heylen wrote:
# HG changeset patch
# User Jan Heylen <heyl...@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

I guess the intention is to ship it in 0.3 so it should be something like _3_0.

@@ -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)

What database have you tested on? With postgresql I get
sqlalchemy.exc.IntegrityError: (IntegrityError) column "draft" contains null values
 '\nALTER TABLE changeset_comments ALTER COLUMN draft SET NOT NULL' {}

Why is populate_default=False ? No other upgrade scripts use that.

+    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)

I guess we also want to include this field in the indices or add extra indices.

author = relationship('User')
      repo = relationship('Repository')

_______________________________________________
kallithea-general mailing list
kallithea-general@sfconservancy.org
http://lists.sfconservancy.org/mailman/listinfo/kallithea-general

Reply via email to