Skip to content

Commit 77419e5

Browse files
committed
fix mssql tests
1 parent 15c8943 commit 77419e5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/Tqdev/PhpCrudApi/Database/GenericDefinition.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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)";

0 commit comments

Comments
 (0)