Skip to content

Commit

Permalink
Add cmd 'db stun' to deactivate cron and mail servers
Browse files Browse the repository at this point in the history
  • Loading branch information
katyukha committed Mar 1, 2023
1 parent fe3ea9e commit e9a37a9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions subpackages/cli/source/odood/cli/commands/database.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module odood.cli.commands.database;

private import std.logger;
private import std.stdio;
private import std.format: format;
private import std.exception: enforce;
Expand Down Expand Up @@ -217,6 +218,30 @@ class CommandDatabaseRestore: OdoodCommand {
}


class CommandDatabaseStun: OdoodCommand {
this() {
super("stun", "Stun database (disable cron and main servers).");
this.add(new Argument(
"name", "Name of database to stun.").required());
}

public override void execute(ProgramArgs args) {
auto project = Project.loadProject;
auto dbname = args.arg("name");
infof("Disabling cron jobs and mail servers on database %s...".format(
dbname));
project.runSQLScript(
dbname,
"UPDATE fetchmail_server SET active=False;
UPDATE ir_mail_server SET active=False;
UPDATE ir_cron SET active=False;",
false);
infof("Cron jobs and mail servers for database %s disabled!".format(
dbname));
}
}


class CommandDatabase: OdoodCommand {
this() {
super("db", "Database management commands");
Expand All @@ -228,6 +253,7 @@ class CommandDatabase: OdoodCommand {
this.add(new CommandDatabaseCopy());
this.add(new CommandDatabaseBackup());
this.add(new CommandDatabaseRestore());
this.add(new CommandDatabaseStun());
}
}

Expand Down

0 comments on commit e9a37a9

Please sign in to comment.