|
6 | 6 | use Doctrine\DBAL\Schema\ForeignKeyConstraint;
|
7 | 7 | use Doctrine\DBAL\Schema\Index;
|
8 | 8 | use Doctrine\DBAL\Schema\Schema;
|
| 9 | +use Doctrine\DBAL\Schema\SchemaConfig; |
9 | 10 | use Doctrine\DBAL\Schema\Table;
|
10 | 11 |
|
11 | 12 | /**
|
|
16 | 17 | */
|
17 | 18 | class SchemaNormalizer
|
18 | 19 | {
|
19 |
| - /** @var Schema */ |
20 |
| - protected $schema; |
| 20 | + protected Schema $schema; |
| 21 | + protected SchemaConfig $schemaConfig; |
21 | 22 |
|
22 | 23 | /**
|
23 | 24 | * Normalize a Schema object into an array descriptor
|
24 |
| - * @param Schema $schema |
25 | 25 | * @return array
|
26 | 26 | */
|
27 |
| - public function normalize(Schema $schema): array |
| 27 | + public function normalize(Schema $schema, SchemaConfig $schemaConfig): array |
28 | 28 | {
|
29 | 29 | $this->schema = $schema;
|
| 30 | + $this->schemaConfig = $schemaConfig; |
30 | 31 | $schemaDesc = [];
|
| 32 | + if (!empty($this->schemaConfig->getDefaultTableOptions())) { |
| 33 | + $schemaDesc['default_table_options'] = $this->schemaConfig->getDefaultTableOptions(); |
| 34 | + } |
31 | 35 | $schemaDesc['tables'] = [];
|
32 | 36 | foreach ($schema->getTables() as $table) {
|
33 | 37 | $schemaDesc['tables'][$table->getName()] = $this->normalizeTable($table);
|
@@ -107,7 +111,10 @@ protected function normalizeColumn(Column $column, bool $isPrimaryKey)
|
107 | 111 | $columnDesc['comment'] = $column->getComment();
|
108 | 112 | }
|
109 | 113 | if (!empty($column->getPlatformOptions())) {
|
110 |
| - $columnDesc['custom'] = $column->getPlatformOptions(); |
| 114 | + $custom = array_diff_assoc($column->getPlatformOptions(), $this->schemaConfig->getDefaultTableOptions()); |
| 115 | + if (!empty($custom)) { |
| 116 | + $columnDesc['custom'] = $custom; |
| 117 | + } |
111 | 118 | }
|
112 | 119 |
|
113 | 120 | if (count($columnDesc) > 1) {
|
|
0 commit comments