-- +goose Up
CREATE TABLE saved_recipes (
    id              UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
    user_id         UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    title           TEXT NOT NULL,
    description     TEXT,
    cuisine         TEXT,
    difficulty      TEXT,
    prep_time_min   INT,
    cook_time_min   INT,
    servings        INT,
    image_url       TEXT,
    ingredients     JSONB NOT NULL DEFAULT '[]',
    steps           JSONB NOT NULL DEFAULT '[]',
    tags            JSONB NOT NULL DEFAULT '[]',
    nutrition       JSONB,
    source          TEXT NOT NULL DEFAULT 'ai',
    saved_at        TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX idx_saved_recipes_user_id ON saved_recipes(user_id);
CREATE INDEX idx_saved_recipes_saved_at ON saved_recipes(user_id, saved_at DESC);

-- +goose Down
DROP TABLE saved_recipes;
