···11-CREATE TABLE `recipes` (
22- `uri` text GENERATED ALWAYS AS ("author_did" || '/' || "rkey") VIRTUAL,
33- `author_did` text NOT NULL,
44- `rkey` text NOT NULL,
55- `image_ref` text,
66- `title` text NOT NULL,
77- `time` integer DEFAULT 0 NOT NULL,
88- `serves` integer,
99- `description` text,
1010- `ingredients` text NOT NULL,
1111- `ingredients_count` integer GENERATED ALWAYS AS (json_array_length("ingredients")) VIRTUAL,
1212- `steps` text NOT NULL,
1313- `steps_count` integer GENERATED ALWAYS AS (json_array_length("steps")) VIRTUAL,
1414- `created_at` text NOT NULL,
1515- PRIMARY KEY(`author_did`, `rkey`)
1616-);
+46
libs/database/migrations/0000_young_hellcat.sql
···11+CREATE TABLE IF NOT EXISTS "profiles" (
22+ "uri" text GENERATED ALWAYS AS ('at://' || "profiles"."did" || '/blue.recipes.actor.profile/self') STORED,
33+ "cid" text NOT NULL,
44+ "did" text PRIMARY KEY NOT NULL,
55+ "ingested_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL,
66+ "display_name" varchar(640) NOT NULL,
77+ "description" varchar(2500),
88+ "pronouns" varchar(200),
99+ "website" text,
1010+ "avatar" text,
1111+ "banner" text,
1212+ "created_at" text NOT NULL
1313+);
1414+--> statement-breakpoint
1515+CREATE TABLE IF NOT EXISTS "recipes" (
1616+ "uri" text GENERATED ALWAYS AS ('at://' || "recipes"."author_did" || '/blue.recipes.feed.recipe/' || "recipes"."rkey") STORED,
1717+ "cid" text NOT NULL,
1818+ "author_did" text NOT NULL,
1919+ "rkey" text NOT NULL,
2020+ "image" text,
2121+ "title" text NOT NULL,
2222+ "time" integer DEFAULT 0 NOT NULL,
2323+ "serves" integer,
2424+ "description" text,
2525+ "ingredients" jsonb NOT NULL,
2626+ "ingredients_count" integer GENERATED ALWAYS AS (jsonb_array_length("recipes"."ingredients")) STORED,
2727+ "steps" jsonb NOT NULL,
2828+ "steps_count" integer GENERATED ALWAYS AS (jsonb_array_length("recipes"."steps")) STORED,
2929+ "created_at" text NOT NULL,
3030+ "ingested_at" text DEFAULT CURRENT_TIMESTAMP NOT NULL,
3131+ CONSTRAINT "recipes_author_did_rkey_pk" PRIMARY KEY("author_did","rkey")
3232+);
3333+--> statement-breakpoint
3434+DO $$ BEGIN
3535+ ALTER TABLE "recipes" ADD CONSTRAINT "recipes_author_did_profiles_did_fk" FOREIGN KEY ("author_did") REFERENCES "public"."profiles"("did") ON DELETE cascade ON UPDATE no action;
3636+EXCEPTION
3737+ WHEN duplicate_object THEN null;
3838+END $$;
3939+--> statement-breakpoint
4040+CREATE INDEX IF NOT EXISTS "profiles_cid_idx" ON "profiles" USING btree ("cid");--> statement-breakpoint
4141+CREATE INDEX IF NOT EXISTS "profiles_cat_idx" ON "profiles" USING btree ("created_at");--> statement-breakpoint
4242+CREATE INDEX IF NOT EXISTS "profiles_iat_idx" ON "profiles" USING btree ("ingested_at");--> statement-breakpoint
4343+CREATE INDEX IF NOT EXISTS "recipes_title_idx" ON "recipes" USING btree ("title");--> statement-breakpoint
4444+CREATE INDEX IF NOT EXISTS "recipes_cid_idx" ON "recipes" USING btree ("cid");--> statement-breakpoint
4545+CREATE INDEX IF NOT EXISTS "recipes_cat_idx" ON "recipes" USING btree ("created_at");--> statement-breakpoint
4646+CREATE INDEX IF NOT EXISTS "recipes_iat_idx" ON "recipes" USING btree ("ingested_at");
-23
libs/database/migrations/0001_past_umar.sql
···11-ALTER TABLE `recipes` RENAME COLUMN "image_ref" TO "image";--> statement-breakpoint
22-CREATE TABLE `profiles` (
33- `uri` text GENERATED ALWAYS AS ('at://' || "did" || '/?/self') VIRTUAL,
44- `did` text PRIMARY KEY NOT NULL,
55- `ingested_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL,
66- `display_name` text(640) NOT NULL,
77- `description` text(2500),
88- `pronouns` text(200),
99- `website` text,
1010- `avatar` text,
1111- `banner` text,
1212- `created_at` text NOT NULL
1313-);
1414---> statement-breakpoint
1515-CREATE INDEX `profiles_cat_idx` ON `profiles` (`created_at`);--> statement-breakpoint
1616-CREATE INDEX `profiles_iat_idx` ON `profiles` (`ingested_at`);--> statement-breakpoint
1717-ALTER TABLE `recipes` DROP COLUMN `uri`;--> statement-breakpoint
1818-ALTER TABLE `recipes` ADD `uri` text GENERATED ALWAYS AS ('at://' || "author_did" || '/?/' || "rkey") VIRTUAL;--> statement-breakpoint
1919-ALTER TABLE `recipes` ADD `ingested_at` text DEFAULT CURRENT_TIMESTAMP NOT NULL;--> statement-breakpoint
2020-CREATE INDEX `recipes_title_idx` ON `recipes` (`title`);--> statement-breakpoint
2121-CREATE INDEX `recipes_cat_idx` ON `recipes` (`created_at`);--> statement-breakpoint
2222-CREATE INDEX `recipes_iat_idx` ON `recipes` (`ingested_at`);--> statement-breakpoint
2323-ALTER TABLE `recipes` ALTER COLUMN "author_did" TO "author_did" text NOT NULL REFERENCES profiles(did) ON DELETE cascade ON UPDATE no action;
-4
libs/database/migrations/0002_cheerful_venom.sql
···11-ALTER TABLE `profiles` DROP COLUMN `uri`;--> statement-breakpoint
22-ALTER TABLE `profiles` ADD `uri` text GENERATED ALWAYS AS ('at://' || "did" || '/blue.recipes.actor.profile/self') VIRTUAL;--> statement-breakpoint
33-ALTER TABLE `recipes` DROP COLUMN `uri`;--> statement-breakpoint
44-ALTER TABLE `recipes` ADD `uri` text GENERATED ALWAYS AS ('at://' || "author_did" || '/blue.recipes.feed.recipe/' || "rkey") VIRTUAL;
···11-ALTER TABLE `profiles` ADD `cid` text NOT NULL;--> statement-breakpoint
22-CREATE INDEX `profiles_cid_idx` ON `profiles` (`cid`);--> statement-breakpoint
33-ALTER TABLE `recipes` ADD `cid` text NOT NULL;--> statement-breakpoint
44-CREATE INDEX `recipes_cid_idx` ON `recipes` (`cid`);