Skip to content

Commit

Permalink
#11 - Fix skipping 'referencedTable' during migration construction
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Mar 22, 2020
1 parent 632bfd3 commit 4b3ed4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Migration/Action/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ public function getReferences(bool $skipRefSchema = false): Generator
);
}

yield $constraintName => $referencesOptions + [
yield $constraintName => array_merge($referencesOptions, [
sprintf("'referencedTable' => %s", $this->wrapWithQuotes($reference->getReferencedTable())),
"'columns' => [" . join(',', array_unique($referenceColumns)) . "]",
"'referencedColumns' => [" . join(',', array_unique($referencedColumns)) . "]",
sprintf("'onUpdate' => '%s'", $reference->getOnUpdate()),
sprintf("'onDelete' => '%s'", $reference->getOnDelete()),
];
]);
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/cli/GenerateCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function generateWithSkipRefSchema(CliTester $I): void
$content = file_get_contents(codecept_output_dir('1.0.0/cli-skip-ref-schema.php'));

$I->assertFalse(strpos($content, "'referencedSchema' => '$schema',"));
$I->assertNotFalse(strpos($content, "'referencedTable' => 'client',"));
}

/**
Expand All @@ -107,6 +108,7 @@ public function generateWithRefSchema(CliTester $I): void
$content = file_get_contents(codecept_output_dir('1.0.0/cli-skip-ref-schema.php'));

$I->assertNotFalse(strpos($content, "'referencedSchema' => '$schema',"));
$I->assertNotFalse(strpos($content, "'referencedTable' => 'client',"));
}

/**
Expand Down

0 comments on commit 4b3ed4e

Please sign in to comment.