# HG changeset patch # User Marcin Kuzminski # Date 2012-09-03 23:07:34 # Node ID c9baaacb670aad4b830a7f3e33f7331dbf48967e # Parent bf3c976d02ec6d7b59a25adac86b6f81245a8856 Remove null from revision column as for comments inside pull requests to work properly new migration adds column for future simpler main page diff --git a/rhodecode/__init__.py b/rhodecode/__init__.py --- a/rhodecode/__init__.py +++ b/rhodecode/__init__.py @@ -38,7 +38,7 @@ except ImportError: __version__ = ('.'.join((str(each) for each in VERSION[:3])) + '.'.join(VERSION[3:])) -__dbversion__ = 6 # defines current db version for migrations +__dbversion__ = 7 # defines current db version for migrations __platform__ = platform.system() __license__ = 'GPLv3' __py_version__ = sys.version_info diff --git a/rhodecode/lib/db_manage.py b/rhodecode/lib/db_manage.py --- a/rhodecode/lib/db_manage.py +++ b/rhodecode/lib/db_manage.py @@ -254,6 +254,9 @@ class DbManage(object): reg_perm.permission = perm Session().add(reg_perm) + def step_7(self): + pass + upgrade_steps = [0] + range(curr_version + 1, __dbversion__ + 1) # CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE diff --git a/rhodecode/lib/dbmigrate/versions/007_version_1_4_0.py b/rhodecode/lib/dbmigrate/versions/007_version_1_4_0.py new file mode 100644 --- /dev/null +++ b/rhodecode/lib/dbmigrate/versions/007_version_1_4_0.py @@ -0,0 +1,51 @@ +import logging +import datetime + +from sqlalchemy import * +from sqlalchemy.exc import DatabaseError +from sqlalchemy.orm import relation, backref, class_mapper +from sqlalchemy.orm.session import Session +from sqlalchemy.ext.declarative import declarative_base + +from rhodecode.lib.dbmigrate.migrate import * +from rhodecode.lib.dbmigrate.migrate.changeset import * + +from rhodecode.model.meta import Base +from rhodecode.model import meta + +log = logging.getLogger(__name__) + + +def upgrade(migrate_engine): + """ + Upgrade operations go here. + Don't create your own engine; bind migrate_engine to your metadata + """ + + #========================================================================== + # CHANGESET_COMMENTS + #========================================================================== + from rhodecode.lib.dbmigrate.schema.db_1_4_0 import ChangesetComment + tbl_name = ChangesetComment.__tablename__ + tbl = Table(tbl_name, + MetaData(bind=migrate_engine), autoload=True, + autoload_with=migrate_engine) + col = tbl.columns.revision + + # remove nullability from revision field + col.alter(nullable=True) + + #========================================================================== + # REPOSITORY + #========================================================================== + from rhodecode.lib.dbmigrate.schema.db_1_4_0 import Repository + tbl = Repository.__table__ + updated_on = Column('updated_on', DateTime(timezone=False), + nullable=True, unique=None) + # create created on column for future lightweight main page + updated_on.create(table=tbl) + + +def downgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -602,6 +602,7 @@ class Repository(Base, BaseModel): enable_downloads = Column("downloads", Boolean(), nullable=True, unique=None, default=True) description = Column("description", String(10000, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) created_on = Column('created_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now) + updated_on = Column('updated_on', DateTime(timezone=False), nullable=True, unique=None, default=datetime.datetime.now) landing_rev = Column("landing_revision", String(255, convert_unicode=False, assert_unicode=None), nullable=False, unique=False, default=None) enable_locking = Column("enable_locking", Boolean(), nullable=False, unique=None, default=False) _locked = Column("locked", String(255, convert_unicode=False, assert_unicode=None), nullable=True, unique=False, default=None)