Files
t5de-hub/packages/db/drizzle/0016_imports.sql
T
dhkatzandClaude Opus 5.5 7d708aebdb
Pull request / title (pull_request) Successful in 1s
CI / test (pull_request) Successful in 1m15s
CI / image (apps/api/Dockerfile, t5de-hub-api) (pull_request) Skipped
CI / image (apps/web/Dockerfile, t5de-hub-web) (pull_request) Skipped
feat: IMVU imports on the hub: grants, requests and the importer's job queue
Creators grant a catalog leave to import their IMVU products (whole shop less
exclusions, or listed products) from a linked IMVU account, agreeing to a versioned
consent text; the catalog's team accepts or declines. Requests queue covered
products (or add them to the library when imported already), suggest, or count.
Importers claim jobs with the catalog's importer key, get t5de-import tokens, and
the catalog registers imported revisions as published products owned by the creator.
Narrowing or withdrawing a grant withdraws products; unlinking suspends grants;
an hourly batch rechecks imported products with IMVU daily. Website: /imports and
the console's catalog imports page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 19:46:10 -08:00

76 lines
4.7 KiB
SQL

CREATE TABLE "import_grant" (
"id" text PRIMARY KEY NOT NULL,
"catalog_id" text NOT NULL,
"creator_id" text NOT NULL,
"imvu_id" bigint NOT NULL,
"scope" text NOT NULL,
"products" jsonb DEFAULT '[]'::jsonb NOT NULL,
"exclude" jsonb DEFAULT '[]'::jsonb NOT NULL,
"listed" boolean DEFAULT true NOT NULL,
"consent_version" integer NOT NULL,
"consented_at" timestamp with time zone DEFAULT now() NOT NULL,
"consent_kind" text DEFAULT 'verified' NOT NULL,
"evidence" text DEFAULT '' NOT NULL,
"recorded_by" text,
"status" text DEFAULT 'pending' NOT NULL,
"status_reason" text DEFAULT '' NOT NULL,
"decided_at" timestamp with time zone,
"decided_by" text,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "import_job" (
"id" text PRIMARY KEY NOT NULL,
"catalog_id" text NOT NULL,
"grant_id" text NOT NULL,
"imvu_product" bigint NOT NULL,
"kind" text NOT NULL,
"status" text DEFAULT 'queued' NOT NULL,
"imvu_revision" integer,
"reason" text DEFAULT '' NOT NULL,
"attempts" integer DEFAULT 0 NOT NULL,
"claimed_at" timestamp with time zone,
"next_at" timestamp with time zone DEFAULT now() NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "import_request" (
"user_id" text NOT NULL,
"imvu_creator" bigint NOT NULL,
"imvu_product" bigint NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"fulfilled_at" timestamp with time zone,
CONSTRAINT "import_request_user_id_imvu_creator_imvu_product_pk" PRIMARY KEY("user_id","imvu_creator","imvu_product")
);
--> statement-breakpoint
CREATE TABLE "imvu_product_info" (
"id" bigint PRIMARY KEY NOT NULL,
"found" boolean NOT NULL,
"name" text DEFAULT '' NOT NULL,
"creator_id" bigint DEFAULT 0 NOT NULL,
"creator_name" text DEFAULT '' NOT NULL,
"rating" text DEFAULT 'general' NOT NULL,
"purchasable" boolean DEFAULT true NOT NULL,
"checked_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
ALTER TABLE "catalog" ADD COLUMN "importer" text DEFAULT 'off' NOT NULL;--> statement-breakpoint
ALTER TABLE "catalog" ADD COLUMN "importer_key_hash" text;--> statement-breakpoint
ALTER TABLE "product" ADD COLUMN "imvu_product" bigint;--> statement-breakpoint
ALTER TABLE "product_revision" ADD COLUMN "imvu_revision" integer;--> statement-breakpoint
ALTER TABLE "import_grant" ADD CONSTRAINT "import_grant_catalog_id_catalog_id_fk" FOREIGN KEY ("catalog_id") REFERENCES "public"."catalog"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "import_grant" ADD CONSTRAINT "import_grant_creator_id_user_id_fk" FOREIGN KEY ("creator_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "import_grant" ADD CONSTRAINT "import_grant_recorded_by_user_id_fk" FOREIGN KEY ("recorded_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "import_grant" ADD CONSTRAINT "import_grant_decided_by_user_id_fk" FOREIGN KEY ("decided_by") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "import_job" ADD CONSTRAINT "import_job_catalog_id_catalog_id_fk" FOREIGN KEY ("catalog_id") REFERENCES "public"."catalog"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "import_job" ADD CONSTRAINT "import_job_grant_id_import_grant_id_fk" FOREIGN KEY ("grant_id") REFERENCES "public"."import_grant"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "import_request" ADD CONSTRAINT "import_request_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "import_grant_catalog" ON "import_grant" USING btree ("catalog_id","status");--> statement-breakpoint
CREATE INDEX "import_grant_imvu" ON "import_grant" USING btree ("imvu_id","status");--> statement-breakpoint
CREATE INDEX "import_job_queue" ON "import_job" USING btree ("catalog_id","status","next_at");--> statement-breakpoint
CREATE UNIQUE INDEX "import_job_open" ON "import_job" USING btree ("catalog_id","imvu_product") WHERE "import_job"."status" in ('queued', 'claimed');--> statement-breakpoint
CREATE INDEX "import_request_creator" ON "import_request" USING btree ("imvu_creator");--> statement-breakpoint
CREATE INDEX "import_request_product" ON "import_request" USING btree ("imvu_product");--> statement-breakpoint
CREATE UNIQUE INDEX "product_imvu_product" ON "product" USING btree ("imvu_product");