From d225f6188a4ca648033203553dd13e26ef43bd00 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Wed, 18 Mar 2020 15:14:14 +0000 Subject: [PATCH] Fixed method getReferences() --- src/Migration/Action/Generate.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Migration/Action/Generate.php b/src/Migration/Action/Generate.php index 6e7704c..0913ea2 100644 --- a/src/Migration/Action/Generate.php +++ b/src/Migration/Action/Generate.php @@ -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); @@ -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()), ]; } }