On Tue, Apr 14, 2015 at 6:03 PM, Jan Heylen <[email protected]> wrote: > # HG changeset patch > # User Jan Heylen <[email protected]> > # 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')
The upgrade of the database using 'paster upgrade_db my.ini' worked fine. However, what I did notice was that once you upgraded the database, you cannot switch to an older revision anymore, for example using 'hg update <something older>'. When you try to make a comment SQLalchemy complains: IntegrityError: (IntegrityError) changeset_comments.draft may not be NULL u'INSERT INTO changeset_comments (repo_id, revision, pull_request_id, line_no, hl_lines, f_path, user_id, text, created_on, modified_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' (2, u'0b815f10926a02b33027907857b9c9305321da34', None, None, None, None, 3, u'test', '2015-04-22 20:03:03.274006', '2015-04-22 20:03:03.274026') I think this could easily be solved by making sure the draft column is defaulting to false. Best regards, Thomas _______________________________________________ kallithea-general mailing list [email protected] http://lists.sfconservancy.org/mailman/listinfo/kallithea-general
