Skip to content

Commit 46c2c65

Browse files
authored
Add "nativeuuid" type for databases with native uuid support (#2282)
1 parent 508a0c8 commit 46c2c65

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

src/Phinx/Db/Adapter/AdapterInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ interface AdapterInterface
5353
public const PHINX_TYPE_JSON = 'json';
5454
public const PHINX_TYPE_JSONB = 'jsonb';
5555
public const PHINX_TYPE_UUID = 'uuid';
56+
public const PHINX_TYPE_NATIVEUUID = 'nativeuuid';
5657
public const PHINX_TYPE_FILESTREAM = 'filestream';
5758

5859
// Geospatial database types

src/Phinx/Db/Adapter/MysqlAdapter.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,8 @@ public function getSqlType(Literal|string $type, ?int $limit = null): array
11091109
return ['name' => 'tinyint', 'limit' => 1];
11101110
case static::PHINX_TYPE_UUID:
11111111
return ['name' => 'char', 'limit' => 36];
1112+
case static::PHINX_TYPE_NATIVEUUID:
1113+
return ['name' => 'uuid'];
11121114
case static::PHINX_TYPE_YEAR:
11131115
if (!$limit || in_array($limit, [2, 4])) {
11141116
$limit = 4;
@@ -1227,6 +1229,10 @@ public function getPhinxType(string $sqlTypeDef): array
12271229
$type = static::PHINX_TYPE_BINARYUUID;
12281230
}
12291231
break;
1232+
case 'uuid':
1233+
$type = static::PHINX_TYPE_NATIVEUUID;
1234+
$limit = null;
1235+
break;
12301236
}
12311237

12321238
try {

src/Phinx/Db/Adapter/PostgresAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,7 @@ public function getSqlType(Literal|string $type, ?int $limit = null): array
10911091
case static::PHINX_TYPE_DATETIME:
10921092
return ['name' => 'timestamp'];
10931093
case static::PHINX_TYPE_BINARYUUID:
1094+
case static::PHINX_TYPE_NATIVEUUID:
10941095
return ['name' => 'uuid'];
10951096
case static::PHINX_TYPE_BLOB:
10961097
case static::PHINX_TYPE_BINARY:

src/Phinx/Db/Adapter/SqlServerAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,7 @@ public function getSqlType(Literal|string $type, ?int $limit = null): array
10981098
return ['name' => 'bit'];
10991099
case static::PHINX_TYPE_BINARYUUID:
11001100
case static::PHINX_TYPE_UUID:
1101+
case static::PHINX_TYPE_NATIVEUUID:
11011102
return ['name' => 'uniqueidentifier'];
11021103
case static::PHINX_TYPE_FILESTREAM:
11031104
return ['name' => 'varbinary', 'limit' => 'max'];

src/Phinx/Db/Table/Column.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Column
3636
public const TIMESTAMP = AdapterInterface::PHINX_TYPE_TIMESTAMP;
3737
public const UUID = AdapterInterface::PHINX_TYPE_UUID;
3838
public const BINARYUUID = AdapterInterface::PHINX_TYPE_BINARYUUID;
39+
public const NATIVEUUID = AdapterInterface::PHINX_TYPE_NATIVEUUID;
3940
/** MySQL-only column type */
4041
public const MEDIUMINTEGER = AdapterInterface::PHINX_TYPE_MEDIUM_INTEGER;
4142
/** MySQL-only column type */

0 commit comments

Comments
 (0)