Changed product_brand fk

This commit is contained in:
Franck Allimant
2014-06-26 15:50:00 +02:00
parent 13e57e332a
commit 65dd2fb129
5 changed files with 11 additions and 9 deletions

View File

@@ -174,7 +174,7 @@ class BrandTableMap extends TableMap
public function buildRelations() public function buildRelations()
{ {
$this->addRelation('BrandImageRelatedByLogoImageId', '\\Thelia\\Model\\BrandImage', RelationMap::MANY_TO_ONE, array('logo_image_id' => 'id', ), 'SET NULL', 'RESTRICT'); $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('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('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'); $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, // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
ProductTableMap::clearInstancePool();
BrandDocumentTableMap::clearInstancePool(); BrandDocumentTableMap::clearInstancePool();
BrandImageTableMap::clearInstancePool(); BrandImageTableMap::clearInstancePool();
BrandI18nTableMap::clearInstancePool(); BrandI18nTableMap::clearInstancePool();

View File

@@ -210,8 +210,8 @@ class ProductTableMap extends TableMap
public function buildRelations() public function buildRelations()
{ {
$this->addRelation('TaxRule', '\\Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'RESTRICT', 'RESTRICT'); $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('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', ), '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('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('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'); $this->addRelation('ProductSaleElements', '\\Thelia\\Model\\ProductSaleElements', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductSaleElementss');

View File

@@ -155,7 +155,7 @@ class TemplateTableMap extends TableMap
*/ */
public function buildRelations() 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('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('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'); $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, // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool,
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
ProductTableMap::clearInstancePool();
TemplateI18nTableMap::clearInstancePool(); TemplateI18nTableMap::clearInstancePool();
} }

View File

@@ -46,10 +46,10 @@
<column name="meta_keywords" type="LONGVARCHAR" /> <column name="meta_keywords" type="LONGVARCHAR" />
<foreign-key foreignTable="tax_rule" name="fk_product_tax_rule_id" onDelete="RESTRICT" onUpdate="RESTRICT"> <foreign-key foreignTable="tax_rule" name="fk_product_tax_rule_id" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference foreign="id" local="tax_rule_id" /> <reference foreign="id" local="tax_rule_id" />
</foreign-key> </foreign-key>
<foreign-key foreignTable="template" name="fk_product_template" onDelete="SET NULL"> <foreign-key foreignTable="template" name="fk_product_template" onDelete="SET NULL">
<reference foreign="id" local="template_id" /> <reference foreign="id" local="template_id" />
</foreign-key> </foreign-key>
<foreign-key foreignTable="brand" name="fk_product_brand" onDelete="RESTRICT" onUpdate="RESTRICT"> <foreign-key foreignTable="brand" name="fk_product_brand" onDelete="RESTRICT" onUpdate="RESTRICT">
<reference foreign="id" local="brand_id" /> <reference foreign="id" local="brand_id" />
</foreign-key> </foreign-key>

View File

@@ -57,11 +57,13 @@ CREATE TABLE `product`
ON DELETE RESTRICT, ON DELETE RESTRICT,
CONSTRAINT `fk_product_template` CONSTRAINT `fk_product_template`
FOREIGN KEY (`template_id`) FOREIGN KEY (`template_id`)
REFERENCES `template` (`id`), REFERENCES `template` (`id`)
ON DELETE SET NULL,
CONSTRAINT `fk_product_brand` CONSTRAINT `fk_product_brand`
FOREIGN KEY (`brand_id`) FOREIGN KEY (`brand_id`)
REFERENCES `brand` (`id`) REFERENCES `brand` (`id`)
ON DELETE SET NULL ON UPDATE RESTRICT
ON DELETE RESTRICT
) ENGINE=InnoDB; ) ENGINE=InnoDB;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------