Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Jul 14, 2023
1 parent ccb0165 commit 0b6f4b8
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,24 +612,17 @@ public function findUniqueIndexes(TableSchemaInterface $table): array
*/
private function extractColumnType(ColumnSchemaInterface $column): string
{
$dbType = (string) $column->getDbType();

return match (true) {
str_contains($dbType, 'FLOAT'),
str_contains($dbType, 'DOUBLE')
=> self::TYPE_DOUBLE,
str_contains($dbType, 'NUMBER')
=> $column->getScale() === null || $column->getScale() > 0
? self::TYPE_DECIMAL
: self::TYPE_INTEGER,
str_contains($dbType, 'BLOB')
=> self::TYPE_BINARY,
str_contains($dbType, 'CLOB')
=> self::TYPE_TEXT,
str_contains($dbType, 'TIMESTAMP')
=> self::TYPE_TIMESTAMP,
default
=> self::TYPE_STRING,
$dbType = explode('(', (string) $column->getDbType(), 2)[0];

return match ($dbType) {
'FLOAT', 'DOUBLE' => self::TYPE_DOUBLE,
'NUMBER' => $column->getScale() === null || $column->getScale() > 0
? self::TYPE_DECIMAL
: self::TYPE_INTEGER,
'BLOB' => self::TYPE_BINARY,
'CLOB' => self::TYPE_TEXT,
'TIMESTAMP' => self::TYPE_TIMESTAMP,
default => self::TYPE_STRING,
};
}

Expand Down

0 comments on commit 0b6f4b8

Please sign in to comment.