···11+CREATE TABLE "categories" (
22+ "id" bigserial PRIMARY KEY NOT NULL,
33+ "did" text NOT NULL,
44+ "rkey" text NOT NULL,
55+ "cid" text NOT NULL,
66+ "name" text NOT NULL,
77+ "description" text,
88+ "slug" text,
99+ "sort_order" integer,
1010+ "forum_id" bigint,
1111+ "created_at" timestamp with time zone NOT NULL,
1212+ "indexed_at" timestamp with time zone NOT NULL
1313+);
1414+--> statement-breakpoint
1515+CREATE TABLE "forums" (
1616+ "id" bigserial PRIMARY KEY NOT NULL,
1717+ "did" text NOT NULL,
1818+ "rkey" text NOT NULL,
1919+ "cid" text NOT NULL,
2020+ "name" text NOT NULL,
2121+ "description" text,
2222+ "indexed_at" timestamp with time zone NOT NULL
2323+);
2424+--> statement-breakpoint
2525+CREATE TABLE "memberships" (
2626+ "id" bigserial PRIMARY KEY NOT NULL,
2727+ "did" text NOT NULL,
2828+ "rkey" text NOT NULL,
2929+ "cid" text NOT NULL,
3030+ "forum_id" bigint,
3131+ "forum_uri" text NOT NULL,
3232+ "role" text,
3333+ "role_uri" text,
3434+ "joined_at" timestamp with time zone,
3535+ "created_at" timestamp with time zone NOT NULL,
3636+ "indexed_at" timestamp with time zone NOT NULL
3737+);
3838+--> statement-breakpoint
3939+CREATE TABLE "mod_actions" (
4040+ "id" bigserial PRIMARY KEY NOT NULL,
4141+ "did" text NOT NULL,
4242+ "rkey" text NOT NULL,
4343+ "cid" text NOT NULL,
4444+ "action" text NOT NULL,
4545+ "subject_did" text,
4646+ "subject_post_uri" text,
4747+ "forum_id" bigint,
4848+ "reason" text,
4949+ "created_by" text NOT NULL,
5050+ "expires_at" timestamp with time zone,
5151+ "created_at" timestamp with time zone NOT NULL,
5252+ "indexed_at" timestamp with time zone NOT NULL
5353+);
5454+--> statement-breakpoint
5555+CREATE TABLE "posts" (
5656+ "id" bigserial PRIMARY KEY NOT NULL,
5757+ "did" text NOT NULL,
5858+ "rkey" text NOT NULL,
5959+ "cid" text NOT NULL,
6060+ "text" text NOT NULL,
6161+ "forum_uri" text,
6262+ "root_post_id" bigint,
6363+ "parent_post_id" bigint,
6464+ "root_uri" text,
6565+ "parent_uri" text,
6666+ "created_at" timestamp with time zone NOT NULL,
6767+ "indexed_at" timestamp with time zone NOT NULL,
6868+ "deleted" boolean DEFAULT false NOT NULL
6969+);
7070+--> statement-breakpoint
7171+CREATE TABLE "users" (
7272+ "did" text PRIMARY KEY NOT NULL,
7373+ "handle" text,
7474+ "indexed_at" timestamp with time zone NOT NULL
7575+);
7676+--> statement-breakpoint
7777+ALTER TABLE "categories" ADD CONSTRAINT "categories_forum_id_forums_id_fk" FOREIGN KEY ("forum_id") REFERENCES "public"."forums"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
7878+ALTER TABLE "memberships" ADD CONSTRAINT "memberships_did_users_did_fk" FOREIGN KEY ("did") REFERENCES "public"."users"("did") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
7979+ALTER TABLE "memberships" ADD CONSTRAINT "memberships_forum_id_forums_id_fk" FOREIGN KEY ("forum_id") REFERENCES "public"."forums"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
8080+ALTER TABLE "mod_actions" ADD CONSTRAINT "mod_actions_forum_id_forums_id_fk" FOREIGN KEY ("forum_id") REFERENCES "public"."forums"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
8181+ALTER TABLE "posts" ADD CONSTRAINT "posts_did_users_did_fk" FOREIGN KEY ("did") REFERENCES "public"."users"("did") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
8282+ALTER TABLE "posts" ADD CONSTRAINT "posts_root_post_id_posts_id_fk" FOREIGN KEY ("root_post_id") REFERENCES "public"."posts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
8383+ALTER TABLE "posts" ADD CONSTRAINT "posts_parent_post_id_posts_id_fk" FOREIGN KEY ("parent_post_id") REFERENCES "public"."posts"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
8484+CREATE UNIQUE INDEX "categories_did_rkey_idx" ON "categories" USING btree ("did","rkey");--> statement-breakpoint
8585+CREATE UNIQUE INDEX "forums_did_rkey_idx" ON "forums" USING btree ("did","rkey");--> statement-breakpoint
8686+CREATE UNIQUE INDEX "memberships_did_rkey_idx" ON "memberships" USING btree ("did","rkey");--> statement-breakpoint
8787+CREATE INDEX "memberships_did_idx" ON "memberships" USING btree ("did");--> statement-breakpoint
8888+CREATE UNIQUE INDEX "mod_actions_did_rkey_idx" ON "mod_actions" USING btree ("did","rkey");--> statement-breakpoint
8989+CREATE UNIQUE INDEX "posts_did_rkey_idx" ON "posts" USING btree ("did","rkey");--> statement-breakpoint
9090+CREATE INDEX "posts_forum_uri_idx" ON "posts" USING btree ("forum_uri");--> statement-breakpoint
9191+CREATE INDEX "posts_root_post_id_idx" ON "posts" USING btree ("root_post_id");