Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Table::foreignKey() #790

Merged
merged 3 commits into from
Dec 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add integration test for deferred constraints in postgres
  • Loading branch information
markstory committed Dec 22, 2024
commit 18e28dabe74cf99a06d22b7028cb6da9375b4e87
21 changes: 21 additions & 0 deletions tests/TestCase/Db/Adapter/PostgresAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 1518,27 @@ public function testAddForeignKeyWithSchema()
$this->adapter->dropSchema('schema2');
}

public function testAddForeignKeyDeferrable()
{
$refTable = new Table('ref_table', [], $this->adapter);
$refTable->addColumn('field1', 'string')->save();

$table = new Table('table', [], $this->adapter);
$table
->addColumn('ref_table_id', 'integer')
->addForeignKey(
['ref_table_id'],
'ref_table',
['id'],
[
'deferrable' => 'DEFERRED',
]
)
->save();

$this->assertTrue($this->adapter->hasForeignKey($table->getName(), ['ref_table_id']));
}

public function testDropForeignKey()
{
$refTable = new Table('ref_table', [], $this->adapter);
Expand Down
Loading