| @@ 1015-1029 (lines=15) @@ | ||
| 1012 | * @param string $tableName Table name |
|
| 1013 | * @return string |
|
| 1014 | */ |
|
| 1015 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
| 1016 | { |
|
| 1017 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
| 1018 | ||
| 1019 | $def = ' CONSTRAINT "' . $constraintName . '" FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
| 1020 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
| 1021 | if ($foreignKey->getOnDelete()) { |
|
| 1022 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
| 1023 | } |
|
| 1024 | if ($foreignKey->getOnUpdate()) { |
|
| 1025 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
| 1026 | } |
|
| 1027 | ||
| 1028 | return $def; |
|
| 1029 | } |
|
| 1030 | ||
| 1031 | /** |
|
| 1032 | * {@inheritdoc} |
|
| @@ 1074-1088 (lines=15) @@ | ||
| 1071 | * @param \Phinx\Db\Table\ForeignKey $foreignKey |
|
| 1072 | * @return string |
|
| 1073 | */ |
|
| 1074 | protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) |
|
| 1075 | { |
|
| 1076 | $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); |
|
| 1077 | $def = ' CONSTRAINT ' . $this->quoteColumnName($constraintName); |
|
| 1078 | $def .= ' FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; |
|
| 1079 | $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; |
|
| 1080 | if ($foreignKey->getOnDelete()) { |
|
| 1081 | $def .= " ON DELETE {$foreignKey->getOnDelete()}"; |
|
| 1082 | } |
|
| 1083 | if ($foreignKey->getOnUpdate()) { |
|
| 1084 | $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; |
|
| 1085 | } |
|
| 1086 | ||
| 1087 | return $def; |
|
| 1088 | } |
|
| 1089 | ||
| 1090 | /** |
|
| 1091 | * {@inheritdoc} |
|