CREATE TABLE "record_pokes" (
	"id" serial PRIMARY KEY NOT NULL,
	"recordId" integer,
	"pokersRepo" text NOT NULL,
	"atUri" text NOT NULL,
	"indexedAt" time DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "records" (
	"id" serial PRIMARY KEY NOT NULL,
	"rkey" varchar NOT NULL,
	"collection" varchar NOT NULL,
	"repo" varchar NOT NULL,
	"atUri" text NOT NULL,
	"data" jsonb NOT NULL,
	"indexedAt" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "user_pokes" (
	"id" serial PRIMARY KEY NOT NULL,
	"subject" text NOT NULL,
	"poker" text NOT NULL,
	"at_uri" text NOT NULL,
	"indexedAt" time DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "record_pokes" ADD CONSTRAINT "record_pokes_recordId_records_id_fk" FOREIGN KEY ("recordId") REFERENCES "public"."records"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "record_pokes_pokersRepo_index" ON "record_pokes" USING btree ("pokersRepo");--> statement-breakpoint
CREATE INDEX "record_pokes_atUri_index" ON "record_pokes" USING btree ("atUri");--> statement-breakpoint
CREATE INDEX "records_rkey_index" ON "records" USING btree ("rkey");--> statement-breakpoint
CREATE INDEX "records_collection_index" ON "records" USING btree ("collection");--> statement-breakpoint
CREATE INDEX "records_repo_index" ON "records" USING btree ("repo");--> statement-breakpoint
CREATE UNIQUE INDEX "records_atUri_index" ON "records" USING btree ("atUri");--> statement-breakpoint
CREATE INDEX "user_pokes_subject_index" ON "user_pokes" USING btree ("subject");--> statement-breakpoint
CREATE INDEX "user_pokes_poker_index" ON "user_pokes" USING btree ("poker");