[PATCH 1 of 7] drafts: database change
Jan Heylen
heyleke at gmail.com
Fri Apr 24 17:47:30 EDT 2015
On Fri, Apr 24, 2015 at 7:18 PM, Mads Kiilerich <mads at kiilerich.com> wrote:
> On 04/14/2015 06:03 PM, Jan Heylen wrote:
>>
>> # 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
>
>
> 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.
Ok, maybe I need to revisit this one, I know we had an issue in this
area when we were deploying it, could be I forgot the update the
upstream patch.
>
>> + 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.
I wasn't aware of any indices, I'll have a look
>
>
>> author = relationship('User')
>> repo = relationship('Repository')
>
>
More information about the kallithea-general
mailing list