From a0d724cc333bf5141d63d6a0844c1707fe809fd9 Mon Sep 17 00:00:00 2001 From: "Manuel Amador (Rudd-O)" Date: Wed, 1 Sep 2010 11:30:32 -0700 Subject: [PATCH] Write the current schema level out to the database when doing deploydb or setup-databases --- setup/bindir/cloud-setup-databases.in | 7 +++++++ setup/db/schema-level.sql | 1 + wscript | 6 ++++++ 3 files changed, 14 insertions(+) create mode 100644 setup/db/schema-level.sql diff --git a/setup/bindir/cloud-setup-databases.in b/setup/bindir/cloud-setup-databases.in index d1d0154916d..3499a1512cc 100755 --- a/setup/bindir/cloud-setup-databases.in +++ b/setup/bindir/cloud-setup-databases.in @@ -352,3 +352,10 @@ if rootuser: print "Applying file %s to the database on server %s:%s"%(p,host,port) try: run_mysql(text,rootuser,rootpassword,host,port) except CalledProcessError: sys.exit(22) + + p = os.path.join(dbfilepath,"schema-level.sql") + if os.path.isfile(p): + text = file(p).read() + print "Applying file %s to the database on server %s:%s"%(p,host,port) + try: run_mysql(text,rootuser,rootpassword,host,port) + except CalledProcessError: sys.exit(22) diff --git a/setup/db/schema-level.sql b/setup/db/schema-level.sql new file mode 100644 index 00000000000..4f2f0645482 --- /dev/null +++ b/setup/db/schema-level.sql @@ -0,0 +1 @@ +INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) VALUES ('Hidden', 'DEFAULT', 'database', 'schema.level', '2.1.3', 'The schema level of this database'); diff --git a/wscript b/wscript index 2173bd2a26d..25672f11eec 100644 --- a/wscript +++ b/wscript @@ -735,6 +735,12 @@ def deploydb(ctx,virttech=None): after = after + file(p).read() Utils.pprint("GREEN","Reading database code from %s"%p) + p = _join("setup","db","schema-level.sql") + if _exists(p): + p = dev_override(p) + after = after + file(p).read() + Utils.pprint("GREEN","Reading database code from %s"%p) + cmd = ["mysql","--user=%s"%dbuser,"-h",dbhost,"--password=%s"%dbpw] Utils.pprint("GREEN","Deploying post-configuration database scripts to %s (user %s)"%(dbhost,dbuser)) Utils.pprint("BLUE"," ".join(cmd))