Skip to content

Commit

Permalink
Fixed method getReferences()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Mar 18, 2020
1 parent fcf5adf commit d225f61
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Migration/Action/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ public function getIndexes(): Generator
public function getReferences(): Generator
{
foreach ($this->references as $constraintName => $reference) {
$referenceColumns = [];
foreach ($reference->getColumns() as $column) {
$referenceColumns[] = sprintf("'%s'", $column);
}

$referencedColumns = [];
foreach ($reference->getReferencedColumns() as $referencedColumn) {
$referencedColumns[] = $this->wrapWithQuotes($referencedColumn);
Expand All @@ -299,10 +304,10 @@ public function getReferences(): Generator
yield $constraintName => [
sprintf("'referencedTable' => %s", $this->wrapWithQuotes($reference->getReferencedTable())),
sprintf("'referencedSchema' => %s", $this->wrapWithQuotes($reference->getReferencedSchema())),
"'columns' => [" . join(",", array_unique($this->getQuoteWrappedColumns())) . "]",
"'columns' => [" . join(',', array_unique($referenceColumns)) . "]",
"'referencedColumns' => [" . join(',', array_unique($referencedColumns)) . "]",
sprintf("'onUpdate' => %s", $reference->getOnUpdate()),
sprintf("'onDelete' => %s", $reference->getOnDelete()),
sprintf("'onUpdate' => '%s'", $reference->getOnUpdate()),
sprintf("'onDelete' => '%s'", $reference->getOnDelete()),
];
}
}
Expand Down

0 comments on commit d225f61

Please sign in to comment.