-- Author: Hayden Hargreaves (hhargreaves2006@gmail.com)
-- Desc:   Create the recipes table in the database.
-- Date:   06/25/2025

BEGIN;

-- Create the recipes table
CREATE TABLE IF NOT EXISTS Recipes (
  Id SERIAL PRIMARY KEY NOT NULL, 
  Title VARCHAR(128) NOT NULL,
  Description TEXT NOT NULL,
  Instructions VARCHAR(1024)[] NOT NULL,
  Serves INTEGER NOT NULL CHECK (serves >= 0 AND serves <= 16),
  Difficulty INTEGER NOT NULL CHECK (difficulty >= 1 AND difficulty <= 5),
  Duration JSONB NOT NULL,
  Category E_MEAL NOT NULL,
  Ingredients JSONB NOT NULL,
  UserId INTEGER NOT NULL REFERENCES users(id),
  Modified TIMESTAMPTZ,
  Created TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

COMMIT;
