1
0
mirror of synced 2025-01-31 04:21:44 +03:00

[2.0] DDC-109 - Add support for Unique Constraint in OneToMany unidirectional relations

This commit is contained in:
beberlei 2009-11-03 18:33:38 +00:00
parent 7bbdac1c88
commit a72977b33d

View File

@ -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'];
}