Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: "nativeuuid" type for databases with native uuid support #2282

Open
wants to merge 2 commits into
base: 0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Phinx/Db/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/Phinx/Db/Adapter/MysqlAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,8 @@
return ['name' => 'tinyint', 'limit' => 1];
case static::PHINX_TYPE_UUID:
return ['name' => 'char', 'limit' => 36];
case static::PHINX_TYPE_NATIVEUUID:
return ['name' => 'uuid'];

Check warning on line 1108 in src/Phinx/Db/Adapter/MysqlAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Phinx/Db/Adapter/MysqlAdapter.php#L1107-L1108

Added lines #L1107 - L1108 were not covered by tests
case static::PHINX_TYPE_YEAR:
if (!$limit || in_array($limit, [2, 4])) {
$limit = 4;
Expand Down Expand Up @@ -1222,6 +1224,10 @@
$type = static::PHINX_TYPE_BINARYUUID;
}
break;
case 'uuid':
$type = static::PHINX_TYPE_NATIVEUUID;
$limit = null;
break;

Check warning on line 1230 in src/Phinx/Db/Adapter/MysqlAdapter.php

View check run for this annotation

Codecov / codecov/patch

src/Phinx/Db/Adapter/MysqlAdapter.php#L1228-L1230

Added lines #L1228 - L1230 were not covered by tests
}

try {
Expand Down
1 change: 1 addition & 0 deletions src/Phinx/Db/Adapter/PostgresAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/Phinx/Db/Adapter/SqlServerAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
1 change: 1 addition & 0 deletions src/Phinx/Db/Table/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Loading