From 94113515e09a11f98febde62f5e1a6e8ac2ed6f5 Mon Sep 17 00:00:00 2001 From: Matthias Wirtz Date: Sun, 1 Mar 2026 09:24:36 +0100 Subject: [PATCH] add using when changing column type to json --- src/Db/Adapter/PostgresAdapter.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Db/Adapter/PostgresAdapter.php b/src/Db/Adapter/PostgresAdapter.php index 5251ce4a..878f81ee 100644 --- a/src/Db/Adapter/PostgresAdapter.php +++ b/src/Db/Adapter/PostgresAdapter.php @@ -476,6 +476,12 @@ protected function getChangeColumnInstructions( $quotedColumnName, ); } + if (in_array($newColumn->getType(), ['json'])) { + $sql .= sprintf( + ' USING (%s::jsonb)', + $quotedColumnName, + ); + } // NULL and DEFAULT cannot be set while changing column type $sql = preg_replace('/ NOT NULL/', '', $sql); $sql = preg_replace('/ DEFAULT NULL/', '', $sql);