From f2ff88c49bfec72d3e3b7eca5417c98c4222398a Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 6 Feb 2024 11:54:32 -0800 Subject: [PATCH] Fixed JSON migration for Postgres --- .../m240206_035135_convert_json_columns.php | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/migrations/m240206_035135_convert_json_columns.php b/src/migrations/m240206_035135_convert_json_columns.php index b79128e4f18..e0c7c7a7f4e 100644 --- a/src/migrations/m240206_035135_convert_json_columns.php +++ b/src/migrations/m240206_035135_convert_json_columns.php @@ -15,12 +15,24 @@ class m240206_035135_convert_json_columns extends Migration */ public function safeUp(): bool { - $this->alterColumn(Table::DEPRECATIONERRORS, 'traces', $this->json()); - $this->alterColumn(Table::FIELDLAYOUTS, 'config', $this->json()); - $this->alterColumn(Table::GQLSCHEMAS, 'scope', $this->json()); - $this->alterColumn(Table::SECTIONS, 'previewTargets', $this->json()); - $this->alterColumn(Table::USERPREFERENCES, 'preferences', $this->json()); - $this->alterColumn(Table::WIDGETS, 'settings', $this->json()); + $columns = [ + [Table::DEPRECATIONERRORS, 'traces'], + [Table::FIELDLAYOUTS, 'config'], + [Table::GQLSCHEMAS, 'scope'], + [Table::SECTIONS, 'previewTargets'], + [Table::USERPREFERENCES, 'preferences'], + [Table::WIDGETS, 'settings'], + ]; + + foreach ($columns as [$table, $column]) { + if ($this->db->getIsPgsql()) { + $this->execute(<<alterColumn($table, $column, $this->json()); + } + } return true; }