]> xenbits.xensource.com Git - people/liuw/osstest.git/commitdiff
Schema: When creating, check that no updates are applied
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 10 Dec 2015 15:31:37 +0000 (15:31 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 11 Dec 2015 17:02:44 +0000 (17:02 +0000)
If you try to run mg-schema-create on an existing instance it bombs
out right at the beginning because it tries to create the `flights'
table, which already exists.

But in the future the `flights' table might be removed in an update,
which would remove this safety catch.  Then running the create might
partially succeed, leaving debris a production instance.

Detect this situation by looking for applied schema updates, and
bombing out if there are any.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v4: Add comment.

mg-schema-create

index dfc429c340204064c41388f66f2f1d503c7e44a8..9bb3040a3a69f56b46d27acd0821ae0edb7f9735 100755 (executable)
@@ -77,6 +77,14 @@ export OSSTEST_DB_USEREAL_IGNORETEST='.*'
 
 . ./cri-getconfig
 
+# ... Unless some update has been applied which removed `flights':
+updates_applied=$(./mg-schema-update list-applied)
+if [ "x$updates_applied" != x ]; then
+    ./mg-schema-update show
+    echo >&2 'Database already exists with applied updates!'
+    exit 127
+fi
+
 ./mg-schema-update $quietopt check-user
 
 $progress "Populating database..."