Skip to content

Transmogrify reset sequence before post process table (CFM-358) #137

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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