Skip to content

Commit

Permalink
Added option --recreate to 'odood db create' cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
katyukha committed Mar 23, 2023
1 parent 9e31d4a commit 642b048
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions subpackages/cli/source/odood/cli/commands/database.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class CommandDatabaseCreate: OdoodCommand {
this() {
super("create", "Create new odoo database.");
this.add(new Flag("d", "demo", "Load demo data for this db"));
this.add(new Flag(
null, "recreate", "Recreate database if it already exists."));
this.add(new Option(
"l", "lang",
"Language of database, specified as ISO code of language."
Expand All @@ -63,6 +65,17 @@ class CommandDatabaseCreate: OdoodCommand {

auto project = Project.loadProject;
string dbname = args.arg("name");
if (project.lodoo.databaseExists(dbname)) {
if (args.flag("recreate")) {
warningf(
"Dropting database %s before recreating it " ~
"(because --recreate option specified).", dbname);
project.lodoo.databaseDrop(dbname);
} else {
throw new OdoodException(
"Database %s already exists!".format(dbname));
}
}
project.lodoo.databaseCreate(
dbname,
args.flag("demo"),
Expand Down

0 comments on commit 642b048

Please sign in to comment.