SQL

CREATE TABLE "recipes_ingredients"  (
  created_at DATETIME,
  update_at DATETIME,
  id INTEGER NOT NULL,
  position INTEGER,
  recipe_id CHAR(32),
  title VARCHAR,
  note VARCHAR,
  unit_id CHAR(32),
  food_id CHAR(32),
  quantity INTEGER,
  reference_id CHAR(32),
  original_text VARCHAR,
  note_normalized VARCHAR,
  original_text_normalized VARCHAR,
  referenced_recipe_id CHAR(32),
  PRIMARY KEY (id),
  CONSTRAINT fk_recipe_subrecipe FOREIGN KEY(referenced_recipe_id) REFERENCES recipes (id),
  FOREIGN KEY(unit_id) REFERENCES ingredient_units (id),
  FOREIGN KEY(food_id) REFERENCES ingredient_foods (id),
  FOREIGN KEY(recipe_id) REFERENCES recipes (id)
)

+ Add column

Columns

Column Data type Allow null Primary key Actions
created_at DATETIME Rename | Drop
update_at DATETIME Rename | Drop
id INTEGER Rename | Drop
position INTEGER Rename | Drop
recipe_id CHAR(32) Rename | Drop
title VARCHAR Rename | Drop
note VARCHAR Rename | Drop
unit_id CHAR(32) Rename | Drop
food_id CHAR(32) Rename | Drop
quantity INTEGER Rename | Drop
reference_id CHAR(32) Rename | Drop
original_text VARCHAR Rename | Drop
note_normalized VARCHAR Rename | Drop
original_text_normalized VARCHAR Rename | Drop
referenced_recipe_id CHAR(32) Rename | Drop

Foreign Keys

Column Destination
recipe_id recipes.id
food_id ingredient_foods.id
unit_id ingredient_units.id
referenced_recipe_id recipes.id

+ Add index

Indexes

Name Columns Unique SQL Drop?
ix_recipes_ingredients_created_at created_at SQL
CREATE INDEX ix_recipes_ingredients_created_at
ON recipes_ingredients (created_at)
Drop
ix_recipes_ingredients_food_id food_id SQL
CREATE INDEX ix_recipes_ingredients_food_id
ON recipes_ingredients (food_id)
Drop
ix_recipes_ingredients_note_normalized note_normalized SQL
CREATE INDEX ix_recipes_ingredients_note_normalized
ON recipes_ingredients (note_normalized)
Drop
ix_recipes_ingredients_original_text_normalized original_text_normalized SQL
CREATE INDEX ix_recipes_ingredients_original_text_normalized
ON recipes_ingredients (original_text_normalized)
Drop
ix_recipes_ingredients_position position SQL
CREATE INDEX ix_recipes_ingredients_position
ON recipes_ingredients (position)
Drop
ix_recipes_ingredients_referenced_recipe_id referenced_recipe_id SQL
CREATE INDEX ix_recipes_ingredients_referenced_recipe_id
ON recipes_ingredients (referenced_recipe_id)
Drop
ix_recipes_ingredients_unit_id unit_id SQL
CREATE INDEX ix_recipes_ingredients_unit_id
ON recipes_ingredients (unit_id)
Drop