Fixed wrong fk in product table

This commit is contained in:
Franck Allimant
2014-07-01 02:36:46 +02:00
parent ceb5b595a8
commit b4f3e3b60a
5 changed files with 72 additions and 21 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', ), 'RESTRICT', 'RESTRICT', 'Products'); $this->addRelation('Product', '\\Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'brand_id', ), 'SET NULL', '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,6 +200,7 @@ 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

@@ -211,7 +211,7 @@ class ProductTableMap extends TableMap
{ {
$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', ), '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('Brand', '\\Thelia\\Model\\Brand', RelationMap::MANY_TO_ONE, array('brand_id' => 'id', ), 'SET NULL', '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

@@ -49,7 +49,7 @@
</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="SET NULL" onUpdate="RESTRICT"> <foreign-key foreignTable="brand" name="fk_product_brand" onDelete="SET NULL" onUpdate="RESTRICT">
<reference foreign="id" local="brand_id" /> <reference foreign="id" local="brand_id" />
</foreign-key> </foreign-key>

View File

@@ -63,7 +63,7 @@ CREATE TABLE `product`
FOREIGN KEY (`brand_id`) FOREIGN KEY (`brand_id`)
REFERENCES `brand` (`id`) REFERENCES `brand` (`id`)
ON UPDATE RESTRICT ON UPDATE RESTRICT
ON DELETE RESTRICT ON DELETE SET NULL
) ENGINE=InnoDB; ) ENGINE=InnoDB;
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------

View File

@@ -118,18 +118,12 @@ CREATE TABLE `brand`
( (
`id` INTEGER NOT NULL AUTO_INCREMENT, `id` INTEGER NOT NULL AUTO_INCREMENT,
`visible` TINYINT, `visible` TINYINT,
`title` VARCHAR(255), `position` INTEGER,
`description` LONGTEXT,
`chapo` TEXT,
`postscriptum` TEXT,
`meta_title` VARCHAR(255),
`meta_description` TEXT,
`meta_keywords` TEXT,
`logo_image_id` INTEGER, `logo_image_id` INTEGER,
`created_at` DATETIME, `created_at` DATETIME,
`updated_at` DATETIME, `updated_at` DATETIME,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
INDEX `fk_brand_brand_image1_idx` (`logo_image_id`), INDEX `fk_brand_brand_image_idx` (`logo_image_id`),
CONSTRAINT `fk_logo_image_id_brand_image` CONSTRAINT `fk_logo_image_id_brand_image`
FOREIGN KEY (`logo_image_id`) FOREIGN KEY (`logo_image_id`)
REFERENCES `brand_image` (`id`) REFERENCES `brand_image` (`id`)
@@ -149,10 +143,6 @@ CREATE TABLE `brand_document`
`brand_id` INTEGER NOT NULL, `brand_id` INTEGER NOT NULL,
`file` VARCHAR(255) NOT NULL, `file` VARCHAR(255) NOT NULL,
`position` INTEGER, `position` INTEGER,
`title` VARCHAR(255),
`description` LONGTEXT,
`chapo` TEXT,
`postscriptum` TEXT,
`created_at` DATETIME, `created_at` DATETIME,
`updated_at` DATETIME, `updated_at` DATETIME,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
@@ -176,15 +166,10 @@ CREATE TABLE `brand_image`
`brand_id` INTEGER NOT NULL, `brand_id` INTEGER NOT NULL,
`file` VARCHAR(255) NOT NULL, `file` VARCHAR(255) NOT NULL,
`position` INTEGER, `position` INTEGER,
`title` VARCHAR(255),
`description` LONGTEXT,
`chapo` TEXT,
`postscriptum` TEXT,
`created_at` DATETIME, `created_at` DATETIME,
`updated_at` DATETIME, `updated_at` DATETIME,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
INDEX `idx_brand_image_brand_id` (`brand_id`), INDEX `idx_brand_image_brand_id` (`brand_id`),
INDEX `idx_brand_image_brand_id_is_brand_logo` (`brand_id`),
CONSTRAINT `fk_brand_image_brand_id` CONSTRAINT `fk_brand_image_brand_id`
FOREIGN KEY (`brand_id`) FOREIGN KEY (`brand_id`)
REFERENCES `brand` (`id`) REFERENCES `brand` (`id`)
@@ -192,6 +177,71 @@ CREATE TABLE `brand_image`
ON DELETE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB; ) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- brand_i18n
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `brand_i18n`;
CREATE TABLE `brand_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
`chapo` TEXT,
`postscriptum` TEXT,
`meta_title` VARCHAR(255),
`meta_description` TEXT,
`meta_keywords` TEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `brand_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `brand` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- brand_document_i18n
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `brand_document_i18n`;
CREATE TABLE `brand_document_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
`chapo` TEXT,
`postscriptum` TEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `brand_document_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `brand_document` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- brand_image_i18n
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `brand_image_i18n`;
CREATE TABLE `brand_image_i18n`
(
`id` INTEGER NOT NULL,
`locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL,
`title` VARCHAR(255),
`description` LONGTEXT,
`chapo` TEXT,
`postscriptum` TEXT,
PRIMARY KEY (`id`,`locale`),
CONSTRAINT `brand_image_i18n_FK_1`
FOREIGN KEY (`id`)
REFERENCES `brand_image` (`id`)
ON DELETE CASCADE
) ENGINE=InnoDB;
-- --------------------------------------------------------- -- ---------------------------------------------------------
-- Add brand field to product table, and related constraint. -- Add brand field to product table, and related constraint.