~ubuntu-server-dev/glance/precise-essex

« back to all changes in this revision

Viewing changes to debian/patches/disable_db_table_auto_create.patch

  • Committer: Chuck Short
  • Date: 2012-04-12 19:31:27 UTC
  • mfrom: (142.1.4 glance-proposed)
  • Revision ID: zulcss@ubuntu.com-20120412193127-in8n3qe079tymk95
* debian/patches/fix_migration_012_foreign_keys.patch: Fix a migration issue
  around missing FKs. Cherry-picked from upstream.  Can be dropped with
  first stable update.
* debian/patches/convert_properties_to_uuid.patch: Fixes migration 012 to
  also convert kernel_id and ramdisk_ids to UUID. Cherry picked from upstream.
  Can be dropped with first stable update (LP: #975651)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
Index: glance/glance/registry/db/api.py
19
19
===================================================================
20
 
--- glance.orig/glance/registry/db/api.py       2012-04-06 14:36:59.876739784 -0700
21
 
+++ glance/glance/registry/db/api.py    2012-04-06 14:37:01.372739856 -0700
 
20
--- glance.orig/glance/registry/db/api.py       2012-04-12 12:26:21.294886517 -0700
 
21
+++ glance/glance/registry/db/api.py    2012-04-12 12:26:24.654886685 -0700
22
22
@@ -23,6 +23,7 @@
23
23
 """
24
24
 
87
87
 def check_mutate_authorization(context, image_ref):
88
88
Index: glance/run_tests.py
89
89
===================================================================
90
 
--- glance.orig/run_tests.py    2012-04-06 14:36:33.030620000 -0700
91
 
+++ glance/run_tests.py 2012-04-06 14:37:58.972742603 -0700
 
90
--- glance.orig/run_tests.py    2012-04-12 12:26:21.310886517 -0700
 
91
+++ glance/run_tests.py 2012-04-12 12:26:24.654886685 -0700
92
92
@@ -284,6 +284,10 @@
93
93
     logger.addHandler(hdlr)
94
94
     logger.setLevel(logging.DEBUG)
100
100
     c = config.Config(stream=sys.stdout,
101
101
                       env=os.environ,
102
102
                       verbosity=3,
 
103
Index: glance/glance/registry/db/migration.py
 
104
===================================================================
 
105
--- glance.orig/glance/registry/db/migration.py 2012-04-12 12:26:21.278886515 -0700
 
106
+++ glance/glance/registry/db/migration.py      2012-04-12 12:26:24.654886685 -0700
 
107
@@ -119,14 +119,25 @@
 
108
     :retval version number
 
109
     """
 
110
     sql_connection = conf.sql_connection
 
111
+    repo_path = get_migrate_repo_path()
 
112
+    latest = versioning_repository.Repository(repo_path).latest
 
113
+
 
114
+    version = version or latest
 
115
+
 
116
     try:
 
117
-        _version_control(conf, current_version)
 
118
-    except versioning_exceptions.DatabaseAlreadyControlledError, e:
 
119
-        if current_version is not None:
 
120
-            msg = (_("database '%(sql_connection)s' is already under "
 
121
-                     "migration control") % locals())
 
122
-            raise exception.DatabaseMigrationError(msg)
 
123
+        # Attempt to get migration_repo version.  Should succeed
 
124
+        # if db was created under version control.
 
125
+        db_version(conf)
 
126
+    except exception.DatabaseMigrationError:
 
127
+        # If it was not created under VC, do nothing until user puts it
 
128
+        # under VC and sets appropriate version.
 
129
+        msg = (_("Database '%(sql_connection)s' does not appear to be under "
 
130
+                 "version control.  Refusing to migrate.  You can enable  "
 
131
+                 "version control for by using 'glance-manage version_control "
 
132
+                 " [VERSION #]") % locals())
 
133
+        raise exception.DatabaseMigrationError(msg)
 
134
 
 
135
+    # Migrate to the latest
 
136
     upgrade(conf, version=version)
 
137
 
 
138