File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88use Doctrine \DBAL \Platforms \AbstractPlatform ;
99use Doctrine \DBAL \Schema \AbstractAsset ;
1010use Doctrine \DBAL \Schema \AbstractSchemaManager ;
11+ use Doctrine \DBAL \Schema \ColumnEditor ;
1112use Doctrine \DBAL \Schema \ComparatorConfig ;
1213use Doctrine \DBAL \Schema \DefaultExpression ;
1314use Doctrine \DBAL \Schema \DefaultExpression \CurrentDate ;
@@ -259,7 +260,18 @@ public function getSchemaFromMetadata(array $classes): Schema
259260 $ this ->platform ,
260261 );
261262 // TODO: This seems rather hackish, can we optimize it?
262- $ table ->getColumn ($ columnName )->setAutoincrement (false );
263+ // Use new column editor API only when new schema editor API is available (DBAL 4.5+)
264+ // @phpstan-ignore function.impossibleType (Using unreleased Schema::edit() API for version detection)
265+ if (method_exists (Schema::class, 'edit ' )) {
266+ // New API: modify column using table editor (creates new table object)
267+ // This is safe because we'll add the table to schema later after all modifications
268+ $ table = $ table ->edit ()->modifyColumnByUnquotedName (
269+ $ columnName ,
270+ static fn (ColumnEditor $ column ) => $ column ->setAutoincrement (false ),
271+ )->create ();
272+ } else {
273+ $ table ->getColumn ($ columnName )->setAutoincrement (false );
274+ }
263275
264276 $ pkColumns [] = $ columnName ;
265277 $ inheritedKeyColumns [] = $ columnName ;
You can’t perform that action at this time.
0 commit comments