changeset 4223:400fbab35389 kallithea-2.2.5-rebrand

db: introduce DB_MIGRATIONS to handle the db_migrate version which has the product name in the key.
author Bradley M. Kuhn <bkuhn@sfconservancy.org>
date Wed, 02 Jul 2014 19:08:37 -0400
parents f5c9018a5cf0
children 1142ebbf04cd
files kallithea/__init__.py kallithea/lib/db_manage.py kallithea/lib/dbmigrate/migrate.cfg kallithea/lib/dbmigrate/migrate/versioning/repository.py
diffstat 4 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/__init__.py	Wed Jul 02 19:08:37 2014 -0400
+++ b/kallithea/__init__.py	Wed Jul 02 19:08:37 2014 -0400
@@ -64,6 +64,9 @@
 # Users.extern_type and .extern_name value for local users
 EXTERN_TYPE_INTERNAL = BRAND if BRAND != 'kallithea' else 'internal'
 
+# db_migrate_version.repository_id value, same as kallithea/lib/dbmigrate/migrate.cfg
+DB_MIGRATIONS = BRAND + "_db_migrations"
+
 try:
     from kallithea.lib import get_current_revision
     _rev = get_current_revision(quiet=True)
--- a/kallithea/lib/db_manage.py	Wed Jul 02 19:08:37 2014 -0400
+++ b/kallithea/lib/db_manage.py	Wed Jul 02 19:08:37 2014 -0400
@@ -34,7 +34,7 @@
 from os.path import dirname as dn, join as jn
 import datetime
 
-from kallithea import __dbversion__, __py_version__, EXTERN_TYPE_INTERNAL
+from kallithea import __dbversion__, __py_version__, EXTERN_TYPE_INTERNAL, DB_MIGRATIONS
 from kallithea.model.user import UserModel
 from kallithea.lib.utils import ask_ok
 from kallithea.model import init_model
@@ -110,7 +110,7 @@
     def set_db_version(self):
         ver = DbMigrateVersion()
         ver.version = __dbversion__
-        ver.repository_id = 'rhodecode_db_migrations'
+        ver.repository_id = DB_MIGRATIONS
         ver.repository_path = 'versions'
         self.sa.add(ver)
         log.info('db version set to: %s' % __dbversion__)
--- a/kallithea/lib/dbmigrate/migrate.cfg	Wed Jul 02 19:08:37 2014 -0400
+++ b/kallithea/lib/dbmigrate/migrate.cfg	Wed Jul 02 19:08:37 2014 -0400
@@ -1,7 +1,7 @@
 [db_settings]
 # Used to identify which repository this database is versioned under.
 # You can use the name of your project.
-repository_id=rhodecode_db_migrations
+repository_id=kallithea_db_migrations
 
 # The name of the database table used to track the schema version.
 # This name shouldn't already be used by your project.
--- a/kallithea/lib/dbmigrate/migrate/versioning/repository.py	Wed Jul 02 19:08:37 2014 -0400
+++ b/kallithea/lib/dbmigrate/migrate/versioning/repository.py	Wed Jul 02 19:08:37 2014 -0400
@@ -9,6 +9,7 @@
 from pkg_resources import resource_filename
 from tempita import Template as TempitaTemplate
 
+import kallithea
 from kallithea.lib.dbmigrate.migrate import exceptions
 from kallithea.lib.dbmigrate.migrate.versioning import version, pathed, cfgparse
 from kallithea.lib.dbmigrate.migrate.versioning.template import Template
@@ -175,7 +176,11 @@
     @property
     def id(self):
         """Returns repository id specified in config"""
-        return self.config.get('db_settings', 'repository_id')
+        # Adjust the value read from kallithea/lib/dbmigrate/migrate.cfg, normally "kallithea_db_migrations"
+        s = self.config.get('db_settings', 'repository_id')
+        if s == "kallithea_db_migrations":
+            s = kallithea.DB_MIGRATIONS
+        return s
 
     @property
     def use_timestamp_numbering(self):