Skip to content

Commit 396aea4

Browse files
authored
Merge pull request #820 from utopia-php/fix-ddl-failures
2 parents 927545f + eb069e2 commit 396aea4

4 files changed

Lines changed: 628 additions & 158 deletions

File tree

src/Database/Adapter.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,26 @@ abstract public function getInternalIndexesKeys(): array;
13651365
*/
13661366
abstract public function getSchemaAttributes(string $collection): array;
13671367

1368+
/**
1369+
* Get the expected column type for a given attribute type.
1370+
*
1371+
* Returns the database-native column type string (e.g. "VARCHAR(255)", "BIGINT")
1372+
* that would be used when creating a column for the given attribute parameters.
1373+
* Returns an empty string if the adapter does not support this operation.
1374+
*
1375+
* @param string $type
1376+
* @param int $size
1377+
* @param bool $signed
1378+
* @param bool $array
1379+
* @param bool $required
1380+
* @return string
1381+
* @throws \Utopia\Database\Exception For unknown types on adapters that support column-type resolution.
1382+
*/
1383+
public function getColumnType(string $type, int $size, bool $signed = true, bool $array = false, bool $required = false): string
1384+
{
1385+
return '';
1386+
}
1387+
13681388
/**
13691389
* Get the query to check for tenant when in shared tables mode
13701390
*

src/Database/Adapter/SQL.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,14 @@ abstract protected function getSQLType(
18291829
bool $required = false
18301830
): string;
18311831

1832+
/**
1833+
* @throws DatabaseException For unknown type values.
1834+
*/
1835+
public function getColumnType(string $type, int $size, bool $signed = true, bool $array = false, bool $required = false): string
1836+
{
1837+
return $this->getSQLType($type, $size, $signed, $array, $required);
1838+
}
1839+
18321840
/**
18331841
* Get SQL Index Type
18341842
*

0 commit comments

Comments
 (0)