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
263263 $ fields = [];
264264 $ constraints = [];
265265 foreach ($ newTable ->getColumnNames () as $ columnName ) {
266+ $ pkColumn = $ this ->getPrimaryKey ($ tableName );
266267 $ newColumn = $ newTable ->getColumn ($ columnName );
267268 $ f1 = $ this ->quote ($ columnName );
268269 $ f2 = $ this ->getColumnType ($ newColumn , false );
269270 $ f3 = $ this ->quote ($ tableName . '_ ' . $ columnName . '_fkey ' );
270271 $ f4 = $ this ->quote ($ newColumn ->getFk ());
271272 $ f5 = $ this ->quote ($ this ->getPrimaryKey ($ newColumn ->getFk ()));
273+ $ f6 = $ this ->quote ($ tableName . '_ ' . $ pkColumn . '_pkey ' );
272274 $ fields [] = "$ f1 $ f2 " ;
273275 if ($ newColumn ->getPk ()) {
274- $ constraints [] = "PRIMARY KEY ( $ f1) " ;
276+ $ constraints [] = "CONSTRAINT $ f6 PRIMARY KEY ($ f1) " ;
275277 }
276278 if ($ newColumn ->getFk ()) {
277279 $ constraints [] = "CONSTRAINT $ f3 FOREIGN KEY ( $ f1) REFERENCES $ f4 ( $ f5) " ;
You can’t perform that action at this time.
0 commit comments