Files
aux-bieaux-legumes/local/modules/Recettes/Config/thelia.sql

68 lines
2.1 KiB
SQL

# This is a fix for InnoDB in MySQL >= 4.1.x
# It "suspends judgement" for fkey relationships until are tables are set.
SET FOREIGN_KEY_CHECKS = 0;
-- ---------------------------------------------------------------------
-- recipe
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `recipe`;
CREATE TABLE `recipe`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`content_id` INTEGER,
`title` VARCHAR(255) NOT NULL,
`people` INTEGER NOT NULL,
`difficulty` INTEGER NOT NULL,
`preparation_time` VARCHAR(255) NOT NULL,
`cooking_time` VARCHAR(255),
PRIMARY KEY (`id`),
INDEX `fi_content_content_id` (`content_id`),
CONSTRAINT `fk_content_content_id`
FOREIGN KEY (`content_id`)
REFERENCES `content` (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- recipe_steps
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `recipe_steps`;
CREATE TABLE `recipe_steps`
(
`recipe_id` INTEGER NOT NULL,
`step` INTEGER NOT NULL,
`description` VARCHAR(255) NOT NULL,
INDEX `fi_recipesteps_recipe_id` (`recipe_id`),
CONSTRAINT `fk_recipesteps_recipe_id`
FOREIGN KEY (`recipe_id`)
REFERENCES `recipe` (`id`)
) ENGINE=InnoDB;
-- ---------------------------------------------------------------------
-- recipe_products
-- ---------------------------------------------------------------------
DROP TABLE IF EXISTS `recipe_products`;
CREATE TABLE `recipe_products`
(
`recipe_id` INTEGER NOT NULL,
`pse_id` INTEGER NOT NULL,
`quantity` INTEGER NOT NULL,
INDEX `fi_recipeproducts_recipe_id` (`recipe_id`),
INDEX `fi_recipeproducts_pse_id` (`pse_id`),
CONSTRAINT `fk_recipeproducts_recipe_id`
FOREIGN KEY (`recipe_id`)
REFERENCES `recipe` (`id`),
CONSTRAINT `fk_recipeproducts_pse_id`
FOREIGN KEY (`pse_id`)
REFERENCES `product_sale_elements` (`id`)
) ENGINE=InnoDB;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;