[2.0] DDC-109 - Add support for Unique Constraint in OneToMany unidirectional relations
This commit is contained in:
parent
7bbdac1c88
commit
a72977b33d
@ -338,7 +338,7 @@ class SchemaTool
|
||||
} else if ($mapping->isManyToMany() && $mapping->isOwningSide) {
|
||||
// create join table
|
||||
$joinTableColumns = array();
|
||||
$joinTableOptions = array();
|
||||
$joinTableOptions = array('primary' => array(), 'uniqueConstraints' => array());
|
||||
$joinTable = $mapping->getJoinTable();
|
||||
|
||||
// Build first FK constraint (relation table => source table)
|
||||
@ -359,6 +359,10 @@ class SchemaTool
|
||||
$constraint1['local'][] = $column['name'];
|
||||
$constraint1['foreign'][] = $joinColumn['referencedColumnName'];
|
||||
|
||||
if($joinColumn['unique'] == true) {
|
||||
$joinTableOptions['uniqueConstraints'][] = array($joinColumn['name']);
|
||||
}
|
||||
|
||||
if (isset($joinColumn['onUpdate'])) {
|
||||
$constraint1['onUpdate'] = $joinColumn['onUpdate'];
|
||||
}
|
||||
@ -388,6 +392,10 @@ class SchemaTool
|
||||
$constraint2['local'][] = $inverseJoinColumn['name'];
|
||||
$constraint2['foreign'][] = $inverseJoinColumn['referencedColumnName'];
|
||||
|
||||
if($inverseJoinColumn['unique'] == true) {
|
||||
$joinTableOptions['uniqueConstraints'][] = array($inverseJoinColumn['name']);
|
||||
}
|
||||
|
||||
if (isset($inverseJoinColumn['onUpdate'])) {
|
||||
$constraint2['onUpdate'] = $inverseJoinColumn['onUpdate'];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user