Skip to content

Commit

Permalink
add migrator support for any DB type
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Feb 9, 2023
1 parent 4d6f25a commit be35392
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/Schema/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,16 @@ public function field(string $fieldName, array $options = []): self
return $this;
}

public function id(string $name = 'id'): self
/**
* @param array<string, mixed> $options
*/
public function id(string $name = 'id', array $options = []): self
{
$options = [
$options = array_merge([
'type' => 'integer',
'ref_type' => self::REF_TYPE_PRIMARY,
'nullable' => false,
];
], $options);

$this->field($name, $options);

Expand Down
2 changes: 1 addition & 1 deletion src/Schema/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function setDb(array $dbData, bool $importData = true): void
$idColumnName = isset($fieldTypes['_id']) ? '_id' : 'id';

// create table
$migrator->id($idColumnName);
$migrator->id($idColumnName, isset($fieldTypes[$idColumnName]) ? ['type' => $fieldTypes[$idColumnName]] : []);
foreach ($fieldTypes as $k => $fieldType) {
if ($k === $idColumnName) {
continue;
Expand Down

0 comments on commit be35392

Please sign in to comment.