|
|
@@ -826,16 +826,7 @@ SQL;
|
|
|
'references' => ['authors', 'id'],
|
|
|
'update' => 'cascade',
|
|
|
'delete' => 'cascade'
|
|
|
- ]);
|
|
|
-
|
|
|
- $expected = <<<SQL
|
|
|
-ALTER TABLE "posts" ADD CONSTRAINT "author_fk" FOREIGN KEY ("author_id") REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;
|
|
|
-SQL;
|
|
|
- $result = $table->addConstraintSql($connection);
|
|
|
- $this->assertCount(1, $result);
|
|
|
- $this->assertTextEquals($expected, $result[0]);
|
|
|
-
|
|
|
- $table
|
|
|
+ ])
|
|
|
->addConstraint('category_fk', [
|
|
|
'type' => 'foreign',
|
|
|
'columns' => ['category_id', 'category_name'],
|
|
|
@@ -844,12 +835,13 @@ SQL;
|
|
|
'delete' => 'cascade'
|
|
|
]);
|
|
|
|
|
|
- $expected = <<<SQL
|
|
|
-ALTER TABLE "posts" ADD CONSTRAINT "category_fk" FOREIGN KEY ("category_id", "category_name") REFERENCES "categories" ("id", "name") ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;
|
|
|
-SQL;
|
|
|
+ $expected = [
|
|
|
+ 'ALTER TABLE "posts" ADD CONSTRAINT "author_fk" FOREIGN KEY ("author_id") REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;',
|
|
|
+ 'ALTER TABLE "posts" ADD CONSTRAINT "category_fk" FOREIGN KEY ("category_id", "category_name") REFERENCES "categories" ("id", "name") ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY IMMEDIATE;'
|
|
|
+ ];
|
|
|
$result = $table->addConstraintSql($connection);
|
|
|
$this->assertCount(2, $result);
|
|
|
- $this->assertTextEquals($expected, $result[1]);
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -883,16 +875,7 @@ SQL;
|
|
|
'references' => ['authors', 'id'],
|
|
|
'update' => 'cascade',
|
|
|
'delete' => 'cascade'
|
|
|
- ]);
|
|
|
-
|
|
|
- $expected = <<<SQL
|
|
|
-ALTER TABLE "posts" DROP CONSTRAINT "author_fk";
|
|
|
-SQL;
|
|
|
- $result = $table->dropConstraintSql($connection);
|
|
|
- $this->assertCount(1, $result);
|
|
|
- $this->assertTextEquals($expected, $result[0]);
|
|
|
-
|
|
|
- $table
|
|
|
+ ])
|
|
|
->addConstraint('category_fk', [
|
|
|
'type' => 'foreign',
|
|
|
'columns' => ['category_id', 'category_name'],
|
|
|
@@ -901,12 +884,13 @@ SQL;
|
|
|
'delete' => 'cascade'
|
|
|
]);
|
|
|
|
|
|
- $expected = <<<SQL
|
|
|
-ALTER TABLE "posts" DROP CONSTRAINT "category_fk";
|
|
|
-SQL;
|
|
|
+ $expected = [
|
|
|
+ 'ALTER TABLE "posts" DROP CONSTRAINT "author_fk";',
|
|
|
+ 'ALTER TABLE "posts" DROP CONSTRAINT "category_fk";'
|
|
|
+ ];
|
|
|
$result = $table->dropConstraintSql($connection);
|
|
|
$this->assertCount(2, $result);
|
|
|
- $this->assertTextEquals($expected, $result[1]);
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
}
|
|
|
|
|
|
/**
|