From: Ian Jackson Date: Thu, 10 Dec 2015 15:31:37 +0000 (+0000) Subject: Schema: When creating, check that no updates are applied X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0133a45e199924edb87881d9bd5ba44cedfb6926;p=people%2Fliuw%2Fosstest.git Schema: When creating, check that no updates are applied 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 Acked-by: Ian Campbell --- v4: Add comment. --- diff --git a/mg-schema-create b/mg-schema-create index dfc429c..9bb3040 100755 --- a/mg-schema-create +++ b/mg-schema-create @@ -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..."