hellth-hub/packages/db/drizzle/0012_right_yellowjacket.sql

22 lines
1.1 KiB
MySQL
Raw Permalink Normal View History

CREATE TABLE "food_nutrition_sources" (
"id" text PRIMARY KEY NOT NULL,
"foodId" text NOT NULL,
"provider" text NOT NULL,
"providerFoodId" text,
"name" text NOT NULL,
"brand" text,
"url" text,
"kcalPer100g" numeric(8, 2) DEFAULT '0' NOT NULL,
"proteinPer100g" numeric(8, 2) DEFAULT '0' NOT NULL,
"carbsPer100g" numeric(8, 2) DEFAULT '0' NOT NULL,
"fatPer100g" numeric(8, 2) DEFAULT '0' NOT NULL,
"servingG" numeric(8, 2),
"confidence" integer DEFAULT 70 NOT NULL,
"raw" jsonb DEFAULT '{}'::jsonb NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL,
"updatedAt" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "food_nutrition_sources" ADD CONSTRAINT "food_nutrition_sources_foodId_foods_id_fk" FOREIGN KEY ("foodId") REFERENCES "public"."foods"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "food_nutrition_sources_food_idx" ON "food_nutrition_sources" USING btree ("foodId");--> statement-breakpoint
CREATE INDEX "food_nutrition_sources_provider_idx" ON "food_nutrition_sources" USING btree ("provider","providerFoodId");