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.
. ./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..."