SPB Git forge

spb/rareindex

Public
54commits 1branches 0releases
7.1 MBsize
maindefault branch
10 days agolast push
TypeScript 61.9% HTML 37.2% SQL 0.7%
2.9 KB · 73 lines sql
Raw Blame History
1CREATE TABLE "certificate_sightings" (2	"id" text PRIMARY KEY NOT NULL,3	"certificate_id" text NOT NULL,4	"kind" text NOT NULL,5	"target_id" text,6	"source_id" text NOT NULL,7	"connector_id" text,8	"source_url" text,9	"price_usd" numeric(18, 4),10	"currency" text,11	"price" numeric(18, 4),12	"observed_at" timestamp with time zone NOT NULL,13	"created_at" timestamp with time zone DEFAULT now() NOT NULL14);15--> statement-breakpoint16CREATE TABLE "certificates" (17	"id" text PRIMARY KEY NOT NULL,18	"grader" text NOT NULL,19	"cert_number" text NOT NULL,20	"asset_id" text,21	"variant_id" text,22	"grade" text,23	"qualifier" text,24	"verify_url" text,25	"first_seen_at" timestamp with time zone NOT NULL,26	"last_seen_at" timestamp with time zone NOT NULL,27	"sightings" integer DEFAULT 0 NOT NULL,28	"source_ids" text[] DEFAULT '{}'::text[] NOT NULL,29	"last_source_url" text,30	"last_price_usd" numeric(18, 4),31	"verified_at" timestamp with time zone,32	"verification" jsonb DEFAULT '{}'::jsonb NOT NULL,33	"created_at" timestamp with time zone DEFAULT now() NOT NULL34);35--> statement-breakpoint36CREATE TABLE "connector_backfills" (37	"id" text PRIMARY KEY NOT NULL,38	"connector_id" text NOT NULL,39	"status" text DEFAULT 'running' NOT NULL,40	"started_at" timestamp with time zone NOT NULL,41	"updated_at" timestamp with time zone DEFAULT now() NOT NULL,42	"finished_at" timestamp with time zone,43	"backfill_start_date" date,44	"backfill_end_date" date,45	"reached_date" date,46	"pages_processed" integer DEFAULT 0 NOT NULL,47	"total_pages" integer,48	"items_processed" integer DEFAULT 0 NOT NULL,49	"last_cursor" jsonb DEFAULT '{}'::jsonb NOT NULL,50	"last_successful_page" integer,51	"runs" integer DEFAULT 0 NOT NULL,52	"errors" integer DEFAULT 0 NOT NULL,53	"retry_count" integer DEFAULT 0 NOT NULL,54	"last_error" text,55	"percent" real56);57--> statement-breakpoint58CREATE TABLE "connector_field_stats" (59	"connector_id" text NOT NULL,60	"day" date NOT NULL,61	"field" text NOT NULL,62	"total" integer DEFAULT 0 NOT NULL,63	"nulls" integer DEFAULT 0 NOT NULL,64	CONSTRAINT "connector_field_stats_connector_id_day_field_pk" PRIMARY KEY("connector_id","day","field")65);66--> statement-breakpoint67ALTER TABLE "connectors" ADD COLUMN "meta" jsonb DEFAULT '{}'::jsonb NOT NULL;--> statement-breakpoint68CREATE INDEX "certificate_sightings_cert_idx" ON "certificate_sightings" USING btree ("certificate_id","observed_at");--> statement-breakpoint69CREATE UNIQUE INDEX "certificate_sightings_uq" ON "certificate_sightings" USING btree ("certificate_id","kind","target_id");--> statement-breakpoint70CREATE UNIQUE INDEX "certificates_grader_cert_uq" ON "certificates" USING btree ("grader","cert_number");--> statement-breakpoint71CREATE INDEX "certificates_asset_idx" ON "certificates" USING btree ("asset_id");--> statement-breakpoint72CREATE INDEX "certificates_last_seen_idx" ON "certificates" USING btree ("last_seen_at");--> statement-breakpoint73CREATE INDEX "connector_backfills_connector_idx" ON "connector_backfills" USING btree ("connector_id","status");