Skip to content

Commit 0e98677

Browse files
committed
Handle deprecated code
1 parent d5c21e9 commit 0e98677

File tree

7 files changed

+24
-7
lines changed

7 files changed

+24
-7
lines changed

src/DBAL/DBALSchema.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace KitLoong\MigrationsGenerator\DBAL;
44

55
use Doctrine\DBAL\Schema\AbstractSchemaManager;
6+
use Doctrine\DBAL\Schema\Table;
67
use Illuminate\Support\Collection;
78
use Illuminate\Support\Facades\DB;
89
use KitLoong\MigrationsGenerator\Schema\Schema;
@@ -41,6 +42,24 @@ public function getTableNames(): Collection
4142
});
4243
}
4344

45+
/**
46+
* Introspects the table with the given name.
47+
* `listTableDetails` is deprecated since `doctrine/dbal` v3.5 and will be removed from v4.
48+
* This method will try to call `introspectTable` and fallback to `listTableDetails`.
49+
*
50+
* @param string $name
51+
* @return \Doctrine\DBAL\Schema\Table
52+
* @throws \Doctrine\DBAL\Exception
53+
*/
54+
protected function introspectTable(string $name): Table
55+
{
56+
if (method_exists($this->dbalSchema, 'introspectTable')) {
57+
return $this->dbalSchema->introspectTable($name);
58+
}
59+
60+
return $this->dbalSchema->listTableDetails($name);
61+
}
62+
4463
/**
4564
* Make a schema manager.
4665
*

src/DBAL/Models/DBALCustomColumn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(string $table, DoctrineDBALColumn $column)
3131
{
3232
$this->name = $column->getName();
3333
$this->tableName = $table;
34-
$this->sqls = DB::getDoctrineSchemaManager()->getDatabasePlatform()->getAlterTableSQL(new TableDiff($this->tableName, [$column]));
34+
$this->sqls = DB::getDoctrineConnection()->getDatabasePlatform()->getAlterTableSQL(new TableDiff($this->tableName, [$column]));
3535
}
3636

3737
/**

src/DBAL/MySQLSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(RegisterColumnType $registerColumnType, MySQLReposit
3333
public function getTable(string $name): Table
3434
{
3535
return new MySQLTable(
36-
$this->dbalSchema->listTableDetails($name),
36+
$this->introspectTable($name),
3737
$this->dbalSchema->listTableColumns($name),
3838
$this->dbalSchema->listTableIndexes($name)
3939
);

src/DBAL/PgSQLSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function getTableNames(): Collection
5757
public function getTable(string $name): Table
5858
{
5959
return new PgSQLTable(
60-
$this->dbalSchema->listTableDetails($name),
60+
$this->introspectTable($name),
6161
$this->dbalSchema->listTableColumns($name),
6262
$this->dbalSchema->listTableIndexes($name)
6363
);

src/DBAL/SQLSrvSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(RegisterColumnType $registerColumnType, SQLSrvReposi
3232
public function getTable(string $name): Table
3333
{
3434
return new SQLSrvTable(
35-
$this->dbalSchema->listTableDetails($name),
35+
$this->introspectTable($name),
3636
$this->dbalSchema->listTableColumns($name),
3737
$this->dbalSchema->listTableIndexes($name)
3838
);

src/DBAL/SQLiteSchema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SQLiteSchema extends DBALSchema
2020
public function getTable(string $name): Table
2121
{
2222
return new SQLiteTable(
23-
$this->dbalSchema->listTableDetails($name),
23+
$this->introspectTable($name),
2424
$this->dbalSchema->listTableColumns($name),
2525
$this->dbalSchema->listTableIndexes($name)
2626
);

src/DBAL/Types/Types.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
final class Types
99
{
1010
// Default built-in types provided by Doctrine DBAL.
11-
public const ARRAY = BuiltInTypes::ARRAY;
1211
public const ASCII_STRING = BuiltInTypes::ASCII_STRING;
1312
public const BIGINT = BuiltInTypes::BIGINT;
1413
public const BINARY = BuiltInTypes::BINARY;
@@ -26,7 +25,6 @@ final class Types
2625
public const GUID = BuiltInTypes::GUID;
2726
public const INTEGER = BuiltInTypes::INTEGER;
2827
public const JSON = BuiltInTypes::JSON;
29-
public const OBJECT = BuiltInTypes::OBJECT;
3028
public const SIMPLE_ARRAY = BuiltInTypes::SIMPLE_ARRAY;
3129
public const SMALLINT = BuiltInTypes::SMALLINT;
3230
public const STRING = BuiltInTypes::STRING;

0 commit comments

Comments
 (0)