# HG changeset patch # User Søren Løvborg # Date 2016-07-18 14:08:43 # Node ID c7ef77ab2f95d33cece49511cb8a4a38e2f61ca2 # Parent 0b6d2ca7175fc90d758d7da86d5452452aca9620 db: remove SQLAlchemy Migrate support The DbMigrateVersion table will be removed in a later changeset. diff --git a/docs/upgrade.rst b/docs/upgrade.rst --- a/docs/upgrade.rst +++ b/docs/upgrade.rst @@ -107,20 +107,7 @@ that you check the contents after the me 6. Upgrade your database ------------------------ -To do this simply run:: - - paster upgrade-db my.ini - -This will upgrade the schema and update some of the defaults in the database, -and will always recheck the settings of the application, if there are no new -options that need to be set. - -.. note:: - The DB schema upgrade library has some limitations and can sometimes fail if you try to - upgrade from older major releases. In such a case simply run upgrades sequentially, e.g., - upgrading from 0.1.X to 0.3.X should be done like this: 0.1.X. > 0.2.X > 0.3.X. - You can always specify what version of Kallithea you want to install e.g. using pip: - ``pip install Kallithea==0.2`` +Not required. 7. Rebuild the Whoosh full-text index diff --git a/kallithea/__init__.py b/kallithea/__init__.py --- a/kallithea/__init__.py +++ b/kallithea/__init__.py @@ -54,9 +54,6 @@ else: # Users.extern_type and .extern_name value for local users EXTERN_TYPE_INTERNAL = 'internal' -# db_migrate_version.repository_id value, same as kallithea/lib/dbmigrate/migrate.cfg -DB_MIGRATIONS = "kallithea_db_migrations" - try: from kallithea.lib import get_current_revision _rev = get_current_revision(quiet=True) diff --git a/kallithea/lib/db_manage.py b/kallithea/lib/db_manage.py --- a/kallithea/lib/db_manage.py +++ b/kallithea/lib/db_manage.py @@ -33,12 +33,12 @@ import uuid import logging from os.path import dirname -from kallithea import __dbversion__, __py_version__, EXTERN_TYPE_INTERNAL, DB_MIGRATIONS +from kallithea import __dbversion__, __py_version__, EXTERN_TYPE_INTERNAL from kallithea.model.user import UserModel from kallithea.lib.utils import ask_ok from kallithea.model import init_model from kallithea.model.db import User, Permission, Ui, \ - Setting, UserToPerm, DbMigrateVersion, RepoGroup, \ + Setting, UserToPerm, RepoGroup, \ UserRepoGroupToPerm, CacheInvalidation, Repository from sqlalchemy.engine import create_engine @@ -105,80 +105,6 @@ class DbManage(object): Base.metadata.create_all(checkfirst=checkfirst) log.info('Created tables for %s', self.dbname) - def set_db_version(self): - ver = DbMigrateVersion() - ver.version = __dbversion__ - ver.repository_id = DB_MIGRATIONS - ver.repository_path = 'versions' - self.sa.add(ver) - log.info('db version set to: %s', __dbversion__) - - def upgrade(self): - """ - Upgrades given database schema to given revision following - all needed steps, to perform the upgrade - - """ - - from kallithea.lib.dbmigrate.migrate.versioning import api - from kallithea.lib.dbmigrate.migrate.exceptions import \ - DatabaseNotControlledError - - if 'sqlite' in self.dburi: - print ( - '********************** WARNING **********************\n' - 'Make sure your version of sqlite is at least 3.7.X. \n' - 'Earlier versions are known to fail on some migrations\n' - '*****************************************************\n') - - upgrade = ask_ok('You are about to perform database upgrade, make ' - 'sure You backed up your database before. ' - 'Continue ? [y/n]') - if not upgrade: - print 'No upgrade performed' - sys.exit(0) - - repository_path = os.path.join(dirname(dirname(dirname(os.path.realpath(__file__)))), - 'kallithea', 'lib', 'dbmigrate') - db_uri = self.dburi - - try: - curr_version = api.db_version(db_uri, repository_path) - msg = ('Found current database under version ' - 'control with version %s' % curr_version) - - except (RuntimeError, DatabaseNotControlledError): - curr_version = 1 - msg = ('Current database is not under version control. Setting ' - 'as version %s' % curr_version) - api.version_control(db_uri, repository_path, curr_version) - - notify(msg) - if curr_version == __dbversion__: - print 'This database is already at the newest version' - sys.exit(0) - - # clear cache keys - log.info("Clearing cache keys now...") - CacheInvalidation.clear_cache() - - upgrade_steps = range(curr_version + 1, __dbversion__ + 1) - notify('attempting to do database upgrade from ' - 'version %s to version %s' % (curr_version, __dbversion__)) - - # CALL THE PROPER ORDER OF STEPS TO PERFORM FULL UPGRADE - _step = None - for step in upgrade_steps: - notify('performing upgrade step %s' % step) - time.sleep(0.5) - - api.upgrade(db_uri, repository_path, step) - notify('schema upgrade for step %s completed' % (step,)) - - _step = step - - notify('upgrade to version %s successful' % _step) - def fix_repo_paths(self): """ Fixes a old kallithea version path into new one without a '*' diff --git a/kallithea/websetup.py b/kallithea/websetup.py --- a/kallithea/websetup.py +++ b/kallithea/websetup.py @@ -41,7 +41,6 @@ def setup_app(command, conf, vars): dbmanage = DbManage(log_sql=True, dbconf=dbconf, root=conf['here'], tests=False, cli_args=command.options.__dict__) dbmanage.create_tables(override=True) - dbmanage.set_db_version() opts = dbmanage.config_prompt(None) dbmanage.create_settings(opts) dbmanage.create_default_user() diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -180,7 +180,6 @@ setup( cache-keys=kallithea.lib.paster_commands.cache_keys:Command ishell=kallithea.lib.paster_commands.ishell:Command make-index=kallithea.lib.paster_commands.make_index:Command - upgrade-db=kallithea.lib.dbmigrate:UpgradeDb celeryd=kallithea.lib.celerypylons.commands:CeleryDaemonCommand install-iis=kallithea.lib.paster_commands.install_iis:Command """,