recipes2/migrations/000001_init.up.sql

37 lines
1.1 KiB
SQL

-- recipe
create table if not exists recipe (
id serial primary key,
title text not null UNIQUE,
description text not null default '',
image varchar(42) not null,
cooking_time varchar(16) not null,
servings smallint not null default 1,
cal varchar(16) not null
);
-- recipe ingredients group
create table if not exists recipe_ingredients_group (
id serial primary key,
recipe_id integer references recipe(id) on delete cascade,
title text default ''
);
-- recipe ingredients
create table if not exists recipe_ingredients (
recipe_ingredients_group_id integer references recipe_ingredients_group(id) on delete cascade,
ingredient text not null
);
-- recipe steps
create table if not exists recipe_steps (
recipe_id integer references recipe(id) on delete cascade,
step_num integer not null,
step_text text not null
);
-- recipe advices
create table if not exists recipe_advices (
recipe_id integer references recipe(id) on delete cascade,
advice text
);
-- recipe categories
create table if not exists recipe_categories (
recipe_id integer references recipe(id) on delete cascade,
category text
);