From: Ian Jackson Subject: [OSSTEST PATCH 8/7] Schema: When creating, check that no updates are applied Date: Thu, 10 Dec 2015 15:34:19 +0000 Message-ID: <1449761659-5951-1-git-send-email-ian.jackson@eu.citrix.com> References: <22121.38894.566485.105360@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a73F3-0001FB-QO for xen-devel@lists.xenproject.org; Thu, 10 Dec 2015 15:34:49 +0000 In-Reply-To: <22121.38894.566485.105360@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org 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 --- mg-schema-create | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mg-schema-create b/mg-schema-create index df5e215..e15ecb9 100755 --- a/mg-schema-create +++ b/mg-schema-create @@ -70,6 +70,13 @@ export OSSTEST_DB_USEREAL_IGNORETEST='.*' . ./cri-getconfig +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..." -- 1.7.10.4