diff --git a/rhodecode/__init__.py b/rhodecode/__init__.py --- a/rhodecode/__init__.py +++ b/rhodecode/__init__.py @@ -51,7 +51,7 @@ except ImportError: __version__ = ('.'.join((str(each) for each in VERSION[:3])) + '.'.join(VERSION[3:])) -__dbversion__ = 13 # defines current db version for migrations +__dbversion__ = 14 # 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 @@ -30,6 +30,7 @@ import time import uuid import logging from os.path import dirname as dn, join as jn +import datetime from rhodecode import __dbversion__, __py_version__ @@ -216,6 +217,13 @@ class UpgradeSteps(object): def step_13(self): pass + def step_14(self): + # fix nullable columns on last_update + for r in RepoModel().get_all(): + if r.updated_on is None: + r.updated_on = datetime.datetime.fromtimestamp(0) + Session().add(r) + Session().commit() class DbManage(object): def __init__(self, log_sql, dbconf, root, tests=False, cli_args={}): diff --git a/rhodecode/lib/dbmigrate/versions/014_version_1_7_1.py b/rhodecode/lib/dbmigrate/versions/014_version_1_7_1.py new file mode 100644 --- /dev/null +++ b/rhodecode/lib/dbmigrate/versions/014_version_1_7_1.py @@ -0,0 +1,38 @@ +import logging +import datetime + +from sqlalchemy import * +from sqlalchemy.exc import DatabaseError +from sqlalchemy.orm import relation, backref, class_mapper, joinedload +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 +from rhodecode.lib.dbmigrate.versions import _reset_base + +log = logging.getLogger(__name__) + + +def upgrade(migrate_engine): + """ + Upgrade operations go here. + Don't create your own engine; bind migrate_engine to your metadata + """ + _reset_base(migrate_engine) + + #========================================================================== + # Gist + #========================================================================== + from rhodecode.lib.dbmigrate.schema.db_1_7_0 import Gist + tbl = Gist.__table__ + user_id = tbl.columns.gist_expires + user_id.alter(type=Float(53)) + + +def downgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine