Skip to content

Commit 9c0efb7

Browse files
DB setup: support db schema creation (with --schema-only) without force recreate option (apache#12004)
1 parent b8ec941 commit 9c0efb7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

setup/bindir/cloud-setup-databases.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ for full help
199199
self.info("No mysql root user specified, will not create Cloud DB schema\n", None)
200200
return
201201

202+
if self.areCloudDatabasesCreated() and not self.options.schemaonly and not self.options.forcerecreate:
203+
self.errorAndExit("Aborting script as the databases (cloud, cloud_usage) already exist.\n" \
204+
"Please use the --force-recreate parameter if you want to recreate the databases and schemas, or use --schema-only if you only want to create the schemas only.")
205+
202206
replacements = (
203207
("CREATE USER cloud identified by 'cloud';",
204208
"CREATE USER %s@`localhost` identified by '%s'; CREATE USER %s@`%%` identified by '%s';"%(
@@ -239,10 +243,6 @@ for full help
239243
("DROP USER 'cloud'@'%' ;", "DO NULL;")
240244
)
241245

242-
if self.areCloudDatabasesCreated() and not self.options.forcerecreate:
243-
self.errorAndExit("Aborting script as the databases (cloud, cloud_usage) already exist.\n" \
244-
"Please use the --force-recreate parameter if you want to recreate the schemas.")
245-
246246
scriptsToRun = ["create-database","create-schema", "create-database-premium","create-schema-premium"]
247247
if self.options.schemaonly:
248248
scriptsToRun = ["create-schema", "create-schema-premium"]
@@ -617,11 +617,11 @@ for example:
617617
self.parser.add_option("-d", "--deploy-as", action="store", type="string", dest="rootcreds", default="",
618618
help="Colon-separated user name and password of a MySQL user with administrative privileges")
619619
self.parser.add_option("-s", "--schema-only", action="store_true", dest="schemaonly", default=False,
620-
help="Creates the db schema without having to pass root credentials - " \
620+
help="Creates the db schema only without having to pass root credentials - " \
621621
"Please note: The databases (cloud, cloud_usage) and user (cloud) has to be configured " \
622622
"manually prior to running this script when using this flag.")
623623
self.parser.add_option("--force-recreate", action="store_true", dest="forcerecreate", default=False,
624-
help="Force recreation of the existing DB schemas. This option is disabled by default." \
624+
help="Force recreation of the existing DB databases and schemas. This option is disabled by default." \
625625
"Please note: The databases (cloud, cloud_usage) and its tables data will be lost and recreated.")
626626

627627
self.parser.add_option("-a", "--auto", action="store", type="string", dest="serversetup", default="",

0 commit comments

Comments
 (0)