CREATE TABLE list_meals (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    list_id INTEGER NOT NULL REFERENCES lists(id) ON DELETE CASCADE,
    meal_id INTEGER REFERENCES meals(id) ON DELETE SET NULL,
    name TEXT NOT NULL,
    created_at INTEGER NOT NULL
);

ALTER TABLE items ADD COLUMN list_meal_id INTEGER REFERENCES list_meals(id) ON DELETE CASCADE;

CREATE INDEX list_meals_list_idx ON list_meals(list_id);
CREATE INDEX items_list_meal_idx ON items(list_meal_id);
