changeset 6014:c7ef77ab2f95

db: remove SQLAlchemy Migrate support The DbMigrateVersion table will be removed in a later changeset.
author Søren Løvborg <sorenl@unity3d.com>
date Mon, 18 Jul 2016 14:08:43 +0200
parents 0b6d2ca7175f
children 968f2d4214e8
files docs/upgrade.rst kallithea/__init__.py kallithea/lib/db_manage.py kallithea/websetup.py setup.py
diffstat 5 files changed, 3 insertions(+), 95 deletions(-) [+]
line wrap: on
line diff
--- a/docs/upgrade.rst	Mon Jul 18 14:03:17 2016 +0200
+++ b/docs/upgrade.rst	Mon Jul 18 14:08:43 2016 +0200
@@ -107,20 +107,7 @@
 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
--- a/kallithea/__init__.py	Mon Jul 18 14:03:17 2016 +0200
+++ b/kallithea/__init__.py	Mon Jul 18 14:08:43 2016 +0200
@@ -54,9 +54,6 @@
 # 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)
--- a/kallithea/lib/db_manage.py	Mon Jul 18 14:03:17 2016 +0200
+++ b/kallithea/lib/db_manage.py	Mon Jul 18 14:08:43 2016 +0200
@@ -33,12 +33,12 @@
 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 @@
         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 '*'
--- a/kallithea/websetup.py	Mon Jul 18 14:03:17 2016 +0200
+++ b/kallithea/websetup.py	Mon Jul 18 14:08:43 2016 +0200
@@ -41,7 +41,6 @@
     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()
--- a/setup.py	Mon Jul 18 14:03:17 2016 +0200
+++ b/setup.py	Mon Jul 18 14:08:43 2016 +0200
@@ -180,7 +180,6 @@
     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
     """,