Define uuid_generate_v7() in the first migration and switch all table primary key defaults to it. Remove the uuid-ossp extension dependency. Update refresh token and request ID generation in Go code to use uuid.NewV7() from the existing google/uuid v1.6.0 library. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
1.3 KiB
SQL
36 lines
1.3 KiB
SQL
-- +goose Up
|
|
|
|
CREATE TABLE menu_plans (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
week_start DATE NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE(user_id, week_start)
|
|
);
|
|
|
|
CREATE TABLE menu_items (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
menu_plan_id UUID NOT NULL REFERENCES menu_plans(id) ON DELETE CASCADE,
|
|
day_of_week INT NOT NULL CHECK (day_of_week BETWEEN 1 AND 7),
|
|
meal_type TEXT NOT NULL CHECK (meal_type IN ('breakfast','lunch','dinner')),
|
|
recipe_id UUID REFERENCES saved_recipes(id) ON DELETE SET NULL,
|
|
recipe_data JSONB,
|
|
UNIQUE(menu_plan_id, day_of_week, meal_type)
|
|
);
|
|
|
|
-- Stores the generated shopping list for a menu plan.
|
|
-- items is a JSONB array of {name, category, amount, unit, checked, in_stock}.
|
|
CREATE TABLE shopping_lists (
|
|
id UUID PRIMARY KEY DEFAULT uuid_generate_v7(),
|
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
menu_plan_id UUID REFERENCES menu_plans(id) ON DELETE CASCADE,
|
|
items JSONB NOT NULL DEFAULT '[]',
|
|
generated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE(user_id, menu_plan_id)
|
|
);
|
|
|
|
-- +goose Down
|
|
DROP TABLE shopping_lists;
|
|
DROP TABLE menu_items;
|
|
DROP TABLE menu_plans;
|