Skip to content

Commit

Permalink
Transmogrify reset sequence before post process table (CFM-358) (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
skoranda authored Dec 30, 2023
1 parent 8b63c59 commit c54ccfc
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions app/src/Command/TransmogrifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,27 +689,14 @@ public function execute(Arguments $args, ConsoleIo $io) {
$this->cliLogPercentage($tally, $count);
}
}

// Run any post processing functions for the table.

if(!empty($this->tables[$t]['postTable'])) {
$p = $this->tables[$t]['postTable'];

$this->$p();
}


// Log warning and error count.
$io->out("<warning>(Warnings: " . $warns . ")</warning>");
$io->out("<error>(Errors: " . $err . ")</error>");

// Reset sequence to next value after current max.
$max = $this->outconn->fetchOne('SELECT MAX(id) FROM ' . $t);
$max++;
$stdout_msg = "(New max: " . $max . ")";
if($warns > 0) {
$stdout_msg .= "<warning>(Warnings: " . $warns . ")</warning>";
}
if($err > 0) {
$stdout_msg .= "<error>(Errors: " . $err . ")</error>";
}

$io->out($stdout_msg);

$this->io->info("Resetting sequence for $t to $max");

// Strictly speaking we should use prepared statements, but we control the
Expand All @@ -721,6 +708,13 @@ public function execute(Arguments $args, ConsoleIo $io) {
$outsql = "ALTER SEQUENCE " . $t . "_id_seq RESTART WITH " . $max;
}
$this->outconn->executeQuery($outsql);

// Run any post processing functions for the table.
if(!empty($this->tables[$t]['postTable'])) {
$p = $this->tables[$t]['postTable'];

$this->$p();
}
}
}

Expand Down

0 comments on commit c54ccfc

Please sign in to comment.