19 lines
1.2 KiB
MySQL
19 lines
1.2 KiB
MySQL
|
|
ALTER TABLE "health_profiles"
|
||
|
|
ADD COLUMN IF NOT EXISTS "dietPreferences" jsonb NOT NULL DEFAULT '["vegetarian","vegan","meat","fish"]'::jsonb,
|
||
|
|
ADD COLUMN IF NOT EXISTS "cooksPerDay" integer NOT NULL DEFAULT 1,
|
||
|
|
ADD COLUMN IF NOT EXISTS "preferredMealPrepDays" integer NOT NULL DEFAULT 0,
|
||
|
|
ADD COLUMN IF NOT EXISTS "meatFishFrequency" text NOT NULL DEFAULT 'flexible';
|
||
|
|
|
||
|
|
CREATE TABLE IF NOT EXISTS "food_user_preferences" (
|
||
|
|
"userId" text NOT NULL,
|
||
|
|
"foodId" text NOT NULL,
|
||
|
|
"vote" integer NOT NULL DEFAULT 0,
|
||
|
|
"updatedAt" timestamp NOT NULL DEFAULT now(),
|
||
|
|
CONSTRAINT "food_user_preferences_userId_foodId_pk" PRIMARY KEY("userId","foodId"),
|
||
|
|
CONSTRAINT "food_user_preferences_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action,
|
||
|
|
CONSTRAINT "food_user_preferences_foodId_foods_id_fk" FOREIGN KEY ("foodId") REFERENCES "public"."foods"("id") ON DELETE cascade ON UPDATE no action
|
||
|
|
);
|
||
|
|
|
||
|
|
CREATE INDEX IF NOT EXISTS "food_user_preferences_user_idx" ON "food_user_preferences" USING btree ("userId");
|
||
|
|
CREATE INDEX IF NOT EXISTS "food_user_preferences_food_idx" ON "food_user_preferences" USING btree ("foodId");
|