diff --git a/src/Db/Adapter/AbstractAdapter.php b/src/Db/Adapter/AbstractAdapter.php index 052a74e3..30da7710 100644 --- a/src/Db/Adapter/AbstractAdapter.php +++ b/src/Db/Adapter/AbstractAdapter.php @@ -87,6 +87,8 @@ abstract class AbstractAdapter implements AdapterInterface, DirectActionInterfac protected ?Connection $connection = null; + protected static array $specificColumnTypes = []; + /** * Class Constructor. * @@ -424,6 +426,17 @@ public function isValidColumnType(Column $column): bool return in_array($column->getType(), $this->getColumnTypes(), true); } + /** + * Add specific column type to adapter. + * + * @param string $type Adapter column type name. + * @return void + */ + public static function addSpecificColumnType(string $type): void + { + static::$specificColumnTypes[] = $type; + } + /** * @inheritDoc */ diff --git a/tests/TestCase/Db/Table/TableTest.php b/tests/TestCase/Db/Table/TableTest.php index 588c8159..664e6c4b 100644 --- a/tests/TestCase/Db/Table/TableTest.php +++ b/tests/TestCase/Db/Table/TableTest.php @@ -108,6 +108,18 @@ public function testAddColumnWithNoAdapterSpecified(): void } } + public function testAddColumnWithSpecificColumnType(): void + { + PostgresAdapter::addSpecificColumnType('my_custom_type'); + $adapter = new PostgresAdapter([]); + $table = new Table('ntable', [], $adapter); + $table->addColumn('email', 'my_custom_type'); + + $actions = $this->getPendingActions($table); + $this->assertInstanceOf(AddColumn::class, $actions[0]); + $this->assertEquals('my_custom_type', $actions[0]->getColumn()->getType()); + } + public function testAddComment(): void { $adapter = new MysqlAdapter([]);