diff --git a/core/lib/Thelia/Model/Map/BrandTableMap.php b/core/lib/Thelia/Model/Map/BrandTableMap.php
index b069e9bbf..55e41bfa5 100644
--- a/core/lib/Thelia/Model/Map/BrandTableMap.php
+++ b/core/lib/Thelia/Model/Map/BrandTableMap.php
@@ -174,7 +174,7 @@ class BrandTableMap extends TableMap
public function buildRelations()
{
$this->addRelation('BrandImageRelatedByLogoImageId', '\\Thelia\\Model\\BrandImage', RelationMap::MANY_TO_ONE, array('logo_image_id' => 'id', ), 'SET NULL', 'RESTRICT');
- $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'brand_id', ), 'SET NULL', null, 'Products');
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'brand_id', ), 'RESTRICT', 'RESTRICT', 'Products');
$this->addRelation('BrandDocument', '\\Thelia\\Model\\BrandDocument', RelationMap::ONE_TO_MANY, array('id' => 'brand_id', ), 'CASCADE', 'RESTRICT', 'BrandDocuments');
$this->addRelation('BrandImageRelatedByBrandId', '\\Thelia\\Model\\BrandImage', RelationMap::ONE_TO_MANY, array('id' => 'brand_id', ), 'CASCADE', 'RESTRICT', 'BrandImagesRelatedByBrandId');
$this->addRelation('BrandI18n', '\\Thelia\\Model\\BrandI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'BrandI18ns');
@@ -200,7 +200,6 @@ class BrandTableMap extends TableMap
{
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
- ProductTableMap::clearInstancePool();
BrandDocumentTableMap::clearInstancePool();
BrandImageTableMap::clearInstancePool();
BrandI18nTableMap::clearInstancePool();
diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php
index 3675ab7e0..64d176029 100644
--- a/core/lib/Thelia/Model/Map/ProductTableMap.php
+++ b/core/lib/Thelia/Model/Map/ProductTableMap.php
@@ -210,8 +210,8 @@ class ProductTableMap extends TableMap
public function buildRelations()
{
$this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'RESTRICT', 'RESTRICT');
- $this->addRelation('Template', '\\Thelia\\Model\\Template', RelationMap::MANY_TO_ONE, array('template_id' => 'id', ), null, null);
- $this->addRelation('Brand', '\\Thelia\\Model\\Brand', RelationMap::MANY_TO_ONE, array('brand_id' => 'id', ), 'SET NULL', null);
+ $this->addRelation('Template', '\\Thelia\\Model\\Template', RelationMap::MANY_TO_ONE, array('template_id' => 'id', ), 'SET NULL', null);
+ $this->addRelation('Brand', '\\Thelia\\Model\\Brand', RelationMap::MANY_TO_ONE, array('brand_id' => 'id', ), 'RESTRICT', 'RESTRICT');
$this->addRelation('ProductCategory', '\\Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductCategories');
$this->addRelation('FeatureProduct', '\\Thelia\\Model\\FeatureProduct', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'FeatureProducts');
$this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductSaleElementss');
diff --git a/core/lib/Thelia/Model/Map/TemplateTableMap.php b/core/lib/Thelia/Model/Map/TemplateTableMap.php
index 901007c03..efcd161bb 100644
--- a/core/lib/Thelia/Model/Map/TemplateTableMap.php
+++ b/core/lib/Thelia/Model/Map/TemplateTableMap.php
@@ -155,7 +155,7 @@ class TemplateTableMap extends TableMap
*/
public function buildRelations()
{
- $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), null, null, 'Products');
+ $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), 'SET NULL', null, 'Products');
$this->addRelation('FeatureTemplate', '\\Thelia\\Model\\FeatureTemplate', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), null, null, 'FeatureTemplates');
$this->addRelation('AttributeTemplate', '\\Thelia\\Model\\AttributeTemplate', RelationMap::ONE_TO_MANY, array('id' => 'template_id', ), null, null, 'AttributeTemplates');
$this->addRelation('TemplateI18n', '\\Thelia\\Model\\TemplateI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'TemplateI18ns');
@@ -183,6 +183,7 @@ class TemplateTableMap extends TableMap
{
// Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
+ ProductTableMap::clearInstancePool();
TemplateI18nTableMap::clearInstancePool();
}
diff --git a/local/config/schema.xml b/local/config/schema.xml
index 11b653378..de1f058ef 100644
--- a/local/config/schema.xml
+++ b/local/config/schema.xml
@@ -46,10 +46,10 @@
-
+
-
+
diff --git a/setup/thelia.sql b/setup/thelia.sql
index 2c7809d99..100e8fd3b 100644
--- a/setup/thelia.sql
+++ b/setup/thelia.sql
@@ -57,11 +57,13 @@ CREATE TABLE `product`
ON DELETE RESTRICT,
CONSTRAINT `fk_product_template`
FOREIGN KEY (`template_id`)
- REFERENCES `template` (`id`),
+ REFERENCES `template` (`id`)
+ ON DELETE SET NULL,
CONSTRAINT `fk_product_brand`
FOREIGN KEY (`brand_id`)
REFERENCES `brand` (`id`)
- ON DELETE SET NULL
+ ON UPDATE RESTRICT
+ ON DELETE RESTRICT
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------