Skip to content

Commit 7c95aea

Browse files
swifferJamison Bryant
authored andcommitted
add using when changing column type to json (#1031)
1 parent 74a30e9 commit 7c95aea

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Db/Adapter/PostgresAdapter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,12 @@ protected function getChangeColumnInstructions(
476476
$quotedColumnName,
477477
);
478478
}
479+
if (in_array($newColumn->getType(), ['json'])) {
480+
$sql .= sprintf(
481+
' USING (%s::jsonb)',
482+
$quotedColumnName,
483+
);
484+
}
479485
// NULL and DEFAULT cannot be set while changing column type
480486
$sql = preg_replace('/ NOT NULL/', '', $sql);
481487
$sql = preg_replace('/ DEFAULT NULL/', '', $sql);

0 commit comments

Comments
 (0)