Skip to content

Commit

Permalink
fix generator for tables with enum fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Illia Sakovich committed Mar 17, 2020
1 parent 175c56b commit f078a31
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/ColumnShouldBeIgnored.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public function __invoke(Column $column): bool
return true;
}

// enum
if ($column->getType()->getName() === 'string' && $column->getLength() === 0) {
return true;
}

if ($column->getName() === 'deleted_at') {
return true;
}
Expand Down
10 changes: 7 additions & 3 deletions src/FactoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ public function generate(Model $model): string

protected function table(Model $model): Table
{
return $this->connection
->getDoctrineSchemaManager()
->listTableDetails($model->getTable());
$schemaManager = $this->connection
->getDoctrineSchemaManager();

$schemaManager->getDatabasePlatform()
->registerDoctrineTypeMapping('enum', 'string');

return $schemaManager->listTableDetails($model->getTable());
}

protected function columns(Table $table): array
Expand Down

0 comments on commit f078a31

Please sign in to comment.