From 1c2b14868bfc6aed96b5986c6e4b479b974a46b1 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 1 May 2021 07:07:32 +0200 Subject: [PATCH] Skip if null --- app/Console/Commands/Correction/FixPostgresSequences.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Console/Commands/Correction/FixPostgresSequences.php b/app/Console/Commands/Correction/FixPostgresSequences.php index 7c3d19fa42..0496b81f2e 100644 --- a/app/Console/Commands/Correction/FixPostgresSequences.php +++ b/app/Console/Commands/Correction/FixPostgresSequences.php @@ -104,6 +104,10 @@ class FixPostgresSequences extends Command $highestId = DB::table($tableToCheck)->select(DB::raw('MAX(id)'))->first(); $nextId = DB::table($tableToCheck)->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))->first(); + if(null === $nextId) { + $this->line(sprintf('nextval is NULL for table "%s"', $tableToCheck)); + continue; + } if ($nextId->nextval < $highestId->max) { DB::select(sprintf('SELECT setval(\'%s_id_seq\', %d)', $tableToCheck, $highestId->max));