CREATE TABLE recipe (
    id                  uuid        PRIMARY KEY DEFAULT gen_random_uuid(),
    household_id        uuid        NOT NULL REFERENCES household (id) ON DELETE CASCADE,
    name                varchar(200) NOT NULL,
    serves              smallint    NOT NULL CHECK (serves BETWEEN 1 AND 20),
    cook_time_min       smallint    NOT NULL CHECK (cook_time_min >= 0),
    effort              varchar(10) NOT NULL CHECK (effort IN ('easy', 'medium', 'hard')),
    is_child_friendly   boolean     NOT NULL DEFAULT false,
    hero_image_url      varchar(500),
    deleted_at          timestamptz,
    created_at          timestamptz NOT NULL DEFAULT now(),
    updated_at          timestamptz NOT NULL DEFAULT now()
);

CREATE INDEX idx_recipe_household ON recipe (household_id) WHERE deleted_at IS NULL;

CREATE TRIGGER set_recipe_updated_at
    BEFORE UPDATE ON recipe
    FOR EACH ROW EXECUTE FUNCTION trigger_set_updated_at();
