@@ -32,15 +32,18 @@ public function normalize(Schema $schema): array
32
32
foreach ($ schema ->getTables () as $ table ) {
33
33
$ schemaDesc ['tables ' ][$ table ->getName ()] = $ this ->normalizeTable ($ table );
34
34
}
35
+ ksort ($ schemaDesc ['tables ' ]);
36
+
35
37
return $ schemaDesc ;
36
38
}
37
39
38
40
protected function normalizeTable (Table $ table )
39
41
{
40
42
$ tableDesc = [];
41
43
42
- if ($ table ->hasPrimaryKey ()) {
43
- $ pk_columns = $ table ->getPrimaryKey ()->getUnquotedColumns ();
44
+ $ primaryKey = $ table ->getPrimaryKey ();
45
+ if ($ primaryKey ) {
46
+ $ pk_columns = $ primaryKey ->getUnquotedColumns ();
44
47
} else {
45
48
$ pk_columns = [];
46
49
}
@@ -103,8 +106,8 @@ protected function normalizeColumn(Column $column, bool $isPrimaryKey)
103
106
if ($ column ->getComment () !== null ) {
104
107
$ columnDesc ['comment ' ] = $ column ->getComment ();
105
108
}
106
- if (!empty ($ column ->getCustomSchemaOptions ())) {
107
- $ columnDesc ['custom ' ] = $ column ->getCustomSchemaOptions ();
109
+ if (!empty ($ column ->getPlatformOptions ())) {
110
+ $ columnDesc ['custom ' ] = $ column ->getPlatformOptions ();
108
111
}
109
112
110
113
if (count ($ columnDesc ) > 1 ) {
@@ -117,10 +120,10 @@ protected function normalizeColumn(Column $column, bool $isPrimaryKey)
117
120
protected function normalizeForeignKeyConstraint (ForeignKeyConstraint $ foreignKeyConstraint )
118
121
{
119
122
$ constraintDesc = [];
120
- if (count ($ foreignKeyConstraint ->getColumns ()) > 1 ) {
121
- $ constraintDesc ['columns ' ] = $ foreignKeyConstraint ->getColumns ();
123
+ if (count ($ foreignKeyConstraint ->getLocalColumns ()) > 1 ) {
124
+ $ constraintDesc ['columns ' ] = $ foreignKeyConstraint ->getLocalColumns ();
122
125
} else {
123
- $ constraintDesc ['column ' ] = $ foreignKeyConstraint ->getColumns ()[0 ];
126
+ $ constraintDesc ['column ' ] = $ foreignKeyConstraint ->getLocalColumns ()[0 ];
124
127
}
125
128
126
129
$ constraintDesc ['references ' ] = $ this ->normalizeForeignReference ($ foreignKeyConstraint );
@@ -135,8 +138,8 @@ protected function normalizeForeignReference(ForeignKeyConstraint $foreignKeyCon
135
138
$ referenceDesc = [];
136
139
$ foreignTableName = $ foreignKeyConstraint ->getForeignTableName ();
137
140
$ foreignTable = $ this ->schema ->getTable ($ foreignTableName );
138
- if ( $ foreignTable ->hasPrimaryKey ()
139
- && $ foreignTable -> getPrimaryKeyColumns () == $ foreignKeyConstraint ->getForeignColumns ()) {
141
+ $ foreignPrimaryKey = $ foreignTable ->getPrimaryKey ();
142
+ if ( $ foreignPrimaryKey && $ foreignPrimaryKey -> getColumns () == $ foreignKeyConstraint ->getForeignColumns ()) {
140
143
$ referenceDesc = $ foreignKeyConstraint ->getForeignTableName ();
141
144
} else {
142
145
$ referenceDesc ['table ' ] = $ foreignKeyConstraint ->getForeignTableName ();
0 commit comments