diff --git a/src/Phinx/Db/Adapter/AdapterInterface.php b/src/Phinx/Db/Adapter/AdapterInterface.php index ecce738af..6afd48167 100644 --- a/src/Phinx/Db/Adapter/AdapterInterface.php +++ b/src/Phinx/Db/Adapter/AdapterInterface.php @@ -53,6 +53,7 @@ interface AdapterInterface public const PHINX_TYPE_JSON = 'json'; public const PHINX_TYPE_JSONB = 'jsonb'; public const PHINX_TYPE_UUID = 'uuid'; + public const PHINX_TYPE_NATIVEUUID = 'nativeuuid'; public const PHINX_TYPE_FILESTREAM = 'filestream'; // Geospatial database types diff --git a/src/Phinx/Db/Adapter/MysqlAdapter.php b/src/Phinx/Db/Adapter/MysqlAdapter.php index e7791c655..76e816a35 100644 --- a/src/Phinx/Db/Adapter/MysqlAdapter.php +++ b/src/Phinx/Db/Adapter/MysqlAdapter.php @@ -1104,6 +1104,8 @@ public function getSqlType(Literal|string $type, ?int $limit = null): array return ['name' => 'tinyint', 'limit' => 1]; case static::PHINX_TYPE_UUID: return ['name' => 'char', 'limit' => 36]; + case static::PHINX_TYPE_NATIVEUUID: + return ['name' => 'uuid']; case static::PHINX_TYPE_YEAR: if (!$limit || in_array($limit, [2, 4])) { $limit = 4; @@ -1222,6 +1224,10 @@ public function getPhinxType(string $sqlTypeDef): array $type = static::PHINX_TYPE_BINARYUUID; } break; + case 'uuid': + $type = static::PHINX_TYPE_NATIVEUUID; + $limit = null; + break; } try { diff --git a/src/Phinx/Db/Adapter/PostgresAdapter.php b/src/Phinx/Db/Adapter/PostgresAdapter.php index 2c9e4567d..adbb3c49d 100644 --- a/src/Phinx/Db/Adapter/PostgresAdapter.php +++ b/src/Phinx/Db/Adapter/PostgresAdapter.php @@ -1072,6 +1072,7 @@ public function getSqlType(Literal|string $type, ?int $limit = null): array case static::PHINX_TYPE_DATETIME: return ['name' => 'timestamp']; case static::PHINX_TYPE_BINARYUUID: + case static::PHINX_TYPE_NATIVEUUID: return ['name' => 'uuid']; case static::PHINX_TYPE_BLOB: case static::PHINX_TYPE_BINARY: diff --git a/src/Phinx/Db/Adapter/SqlServerAdapter.php b/src/Phinx/Db/Adapter/SqlServerAdapter.php index c6ed3a95f..93c82cdd2 100644 --- a/src/Phinx/Db/Adapter/SqlServerAdapter.php +++ b/src/Phinx/Db/Adapter/SqlServerAdapter.php @@ -1092,6 +1092,7 @@ public function getSqlType(Literal|string $type, ?int $limit = null): array return ['name' => 'bit']; case static::PHINX_TYPE_BINARYUUID: case static::PHINX_TYPE_UUID: + case static::PHINX_TYPE_NATIVEUUID: return ['name' => 'uniqueidentifier']; case static::PHINX_TYPE_FILESTREAM: return ['name' => 'varbinary', 'limit' => 'max']; diff --git a/src/Phinx/Db/Table/Column.php b/src/Phinx/Db/Table/Column.php index f677c7760..3941f037e 100644 --- a/src/Phinx/Db/Table/Column.php +++ b/src/Phinx/Db/Table/Column.php @@ -36,6 +36,7 @@ class Column public const TIMESTAMP = AdapterInterface::PHINX_TYPE_TIMESTAMP; public const UUID = AdapterInterface::PHINX_TYPE_UUID; public const BINARYUUID = AdapterInterface::PHINX_TYPE_BINARYUUID; + public const NATIVEUUID = AdapterInterface::PHINX_TYPE_NATIVEUUID; /** MySQL-only column type */ public const MEDIUMINTEGER = AdapterInterface::PHINX_TYPE_MEDIUM_INTEGER; /** MySQL-only column type */