From c54ccfc15a49a7bcd86cbc7beed12f87d9d47fc9 Mon Sep 17 00:00:00 2001 From: Scott Koranda Date: Sat, 30 Dec 2023 22:09:45 +1000 Subject: [PATCH] Transmogrify reset sequence before post process table (CFM-358) (#137) --- app/src/Command/TransmogrifyCommand.php | 32 ++++++++++--------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/app/src/Command/TransmogrifyCommand.php b/app/src/Command/TransmogrifyCommand.php index 43651d127..79d869cbb 100644 --- a/app/src/Command/TransmogrifyCommand.php +++ b/app/src/Command/TransmogrifyCommand.php @@ -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("(Warnings: " . $warns . ")"); + $io->out("(Errors: " . $err . ")"); + + // 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 .= "(Warnings: " . $warns . ")"; - } - if($err > 0) { - $stdout_msg .= "(Errors: " . $err . ")"; - } - - $io->out($stdout_msg); - $this->io->info("Resetting sequence for $t to $max"); // Strictly speaking we should use prepared statements, but we control the @@ -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(); + } } }