File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
src/Tqdev/PhpCrudApi/Database Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -263,15 +263,17 @@ private function getAddTableSQL(ReflectedTable $newTable): String
263
263
$ fields = [];
264
264
$ constraints = [];
265
265
foreach ($ newTable ->getColumnNames () as $ columnName ) {
266
+ $ pkColumn = $ this ->getPrimaryKey ($ tableName );
266
267
$ newColumn = $ newTable ->getColumn ($ columnName );
267
268
$ f1 = $ this ->quote ($ columnName );
268
269
$ f2 = $ this ->getColumnType ($ newColumn , false );
269
270
$ f3 = $ this ->quote ($ tableName . '_ ' . $ columnName . '_fkey ' );
270
271
$ f4 = $ this ->quote ($ newColumn ->getFk ());
271
272
$ f5 = $ this ->quote ($ this ->getPrimaryKey ($ newColumn ->getFk ()));
273
+ $ f6 = $ this ->quote ($ tableName . '_ ' . $ pkColumn . '_pkey ' );
272
274
$ fields [] = "$ f1 $ f2 " ;
273
275
if ($ newColumn ->getPk ()) {
274
- $ constraints [] = "PRIMARY KEY ( $ f1) " ;
276
+ $ constraints [] = "CONSTRAINT $ f6 PRIMARY KEY ($ f1) " ;
275
277
}
276
278
if ($ newColumn ->getFk ()) {
277
279
$ constraints [] = "CONSTRAINT $ f3 FOREIGN KEY ( $ f1) REFERENCES $ f4 ( $ f5) " ;
You can’t perform that action at this time.
0 commit comments