feat(guides): add structured image-first editor
CI / Verify (push) Successful in 1m0s
CI / Build immutable images and deploy (push) Failing after 2m38s

This commit is contained in:
2026-08-29 13:30:52 +00:00 Unverified
parent b8e3b99033
commit dc5c667b4e
36 changed files with 5611 additions and 381 deletions
+198
View File
@@ -0,0 +1,198 @@
CREATE TABLE "artifact_group" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"guide_id" uuid NOT NULL,
"name" text NOT NULL,
"sort_order" integer DEFAULT 0 NOT NULL
);
--> statement-breakpoint
CREATE TABLE "artifact_profile" (
"guide_id" uuid PRIMARY KEY NOT NULL,
"sands" jsonb DEFAULT '[]'::jsonb NOT NULL,
"goblet" jsonb DEFAULT '[]'::jsonb NOT NULL,
"circlet" jsonb DEFAULT '[]'::jsonb NOT NULL,
"substats" jsonb DEFAULT '[]'::jsonb NOT NULL,
"targets" jsonb DEFAULT '[]'::jsonb NOT NULL,
"talents" jsonb DEFAULT '[]'::jsonb NOT NULL,
"note" 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 "artifact_recommendation" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"group_id" uuid NOT NULL,
"catalog_version" varchar(32) NOT NULL,
"first_artifact_key" varchar(64) NOT NULL,
"second_artifact_key" varchar(64),
"percent" numeric(8, 2) NOT NULL,
"sort_order" integer DEFAULT 0 NOT NULL
);
--> statement-breakpoint
CREATE TABLE "catalog_artifact" (
"version" varchar(32) NOT NULL,
"key" varchar(64) NOT NULL,
"name" text NOT NULL,
"image_key" text NOT NULL,
CONSTRAINT "catalog_artifact_version_key_pk" PRIMARY KEY("version","key")
);
--> statement-breakpoint
CREATE TABLE "catalog_character" (
"version" varchar(32) NOT NULL,
"key" varchar(64) NOT NULL,
"name" text NOT NULL,
"element" varchar(48),
"rarity" integer,
"weapon_type" varchar(64),
"image_key" text NOT NULL,
CONSTRAINT "catalog_character_version_key_pk" PRIMARY KEY("version","key")
);
--> statement-breakpoint
CREATE TABLE "catalog_sync_job" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"status" varchar(24) DEFAULT 'pending' NOT NULL,
"version" varchar(32),
"progress" integer DEFAULT 0 NOT NULL,
"total" integer DEFAULT 0 NOT NULL,
"error" text,
"triggered_by_id" text,
"started_at" timestamp with time zone,
"completed_at" timestamp with time zone,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "catalog_version" (
"version" varchar(32) PRIMARY KEY NOT NULL,
"active" boolean DEFAULT false NOT NULL,
"source_timestamp" bigint,
"synced_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "catalog_weapon" (
"version" varchar(32) NOT NULL,
"key" varchar(64) NOT NULL,
"name" text NOT NULL,
"rarity" integer,
"weapon_type" varchar(64),
"image_key" text NOT NULL,
CONSTRAINT "catalog_weapon_version_key_pk" PRIMARY KEY("version","key")
);
--> statement-breakpoint
CREATE TABLE "constellation_recommendation" (
"guide_id" uuid NOT NULL,
"level" integer NOT NULL,
"detail" text NOT NULL,
"cumulative_percent" numeric(8, 2) NOT NULL,
CONSTRAINT "constellation_recommendation_guide_id_level_pk" PRIMARY KEY("guide_id","level")
);
--> statement-breakpoint
CREATE TABLE "extra_section_row" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"section_id" uuid NOT NULL,
"media_id" uuid,
"heading" text NOT NULL,
"body" text NOT NULL,
"percent" numeric(8, 2),
"sort_order" integer DEFAULT 0 NOT NULL
);
--> statement-breakpoint
CREATE TABLE "extra_section" (
"section_id" uuid PRIMARY KEY 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 "guide_section" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"guide_id" uuid NOT NULL,
"kind" varchar(32) NOT NULL,
"slug" varchar(120) NOT NULL,
"title" text NOT NULL,
"enabled" boolean DEFAULT true NOT NULL,
"sort_order" integer DEFAULT 0 NOT NULL
);
--> statement-breakpoint
CREATE TABLE "guide" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"character_key" varchar(64) NOT NULL,
"catalog_version" varchar(32) NOT NULL,
"slug" varchar(120) NOT NULL,
"name" text NOT NULL,
"overview" text NOT NULL,
"cover_media_id" uuid NOT NULL,
"version" integer DEFAULT 1 NOT NULL,
"sort_order" integer DEFAULT 0 NOT NULL,
"trashed_at" timestamp with time zone,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "team_composition" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"guide_id" uuid NOT NULL,
"title" text NOT NULL,
"rotation_seconds" numeric(8, 2) NOT NULL,
"combo" text NOT NULL,
"sort_order" integer DEFAULT 0 NOT NULL
);
--> statement-breakpoint
CREATE TABLE "team_member" (
"team_id" uuid NOT NULL,
"position" integer NOT NULL,
"catalog_version" varchar(32) NOT NULL,
"character_key" varchar(64) NOT NULL,
"damage" numeric(18, 2) NOT NULL,
CONSTRAINT "team_member_team_id_position_pk" PRIMARY KEY("team_id","position")
);
--> statement-breakpoint
CREATE TABLE "weapon_recommendation" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"guide_id" uuid NOT NULL,
"catalog_version" varchar(32) NOT NULL,
"weapon_key" varchar(64) NOT NULL,
"refinement" integer NOT NULL,
"overall_percent" numeric(8, 2),
"personal_percent" numeric(8, 2),
"sort_order" integer DEFAULT 0 NOT NULL
);
--> statement-breakpoint
ALTER TABLE "artifact_group" ADD CONSTRAINT "artifact_group_guide_id_guide_id_fk" FOREIGN KEY ("guide_id") REFERENCES "public"."guide"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "artifact_profile" ADD CONSTRAINT "artifact_profile_guide_id_guide_id_fk" FOREIGN KEY ("guide_id") REFERENCES "public"."guide"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "artifact_recommendation" ADD CONSTRAINT "artifact_recommendation_group_id_artifact_group_id_fk" FOREIGN KEY ("group_id") REFERENCES "public"."artifact_group"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "catalog_artifact" ADD CONSTRAINT "catalog_artifact_version_catalog_version_version_fk" FOREIGN KEY ("version") REFERENCES "public"."catalog_version"("version") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "catalog_character" ADD CONSTRAINT "catalog_character_version_catalog_version_version_fk" FOREIGN KEY ("version") REFERENCES "public"."catalog_version"("version") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "catalog_sync_job" ADD CONSTRAINT "catalog_sync_job_triggered_by_id_user_id_fk" FOREIGN KEY ("triggered_by_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "catalog_weapon" ADD CONSTRAINT "catalog_weapon_version_catalog_version_version_fk" FOREIGN KEY ("version") REFERENCES "public"."catalog_version"("version") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "constellation_recommendation" ADD CONSTRAINT "constellation_recommendation_guide_id_guide_id_fk" FOREIGN KEY ("guide_id") REFERENCES "public"."guide"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "extra_section_row" ADD CONSTRAINT "extra_section_row_section_id_extra_section_section_id_fk" FOREIGN KEY ("section_id") REFERENCES "public"."extra_section"("section_id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "extra_section_row" ADD CONSTRAINT "extra_section_row_media_id_media_id_fk" FOREIGN KEY ("media_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "extra_section" ADD CONSTRAINT "extra_section_section_id_guide_section_id_fk" FOREIGN KEY ("section_id") REFERENCES "public"."guide_section"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guide_section" ADD CONSTRAINT "guide_section_guide_id_guide_id_fk" FOREIGN KEY ("guide_id") REFERENCES "public"."guide"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guide" ADD CONSTRAINT "guide_catalog_version_catalog_version_version_fk" FOREIGN KEY ("catalog_version") REFERENCES "public"."catalog_version"("version") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "guide" ADD CONSTRAINT "guide_cover_media_id_media_id_fk" FOREIGN KEY ("cover_media_id") REFERENCES "public"."media"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "team_composition" ADD CONSTRAINT "team_composition_guide_id_guide_id_fk" FOREIGN KEY ("guide_id") REFERENCES "public"."guide"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "team_member" ADD CONSTRAINT "team_member_team_id_team_composition_id_fk" FOREIGN KEY ("team_id") REFERENCES "public"."team_composition"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "weapon_recommendation" ADD CONSTRAINT "weapon_recommendation_guide_id_guide_id_fk" FOREIGN KEY ("guide_id") REFERENCES "public"."guide"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "artifact_group_order_idx" ON "artifact_group" USING btree ("guide_id","sort_order");--> statement-breakpoint
CREATE INDEX "artifact_recommendation_order_idx" ON "artifact_recommendation" USING btree ("group_id","sort_order");--> statement-breakpoint
CREATE INDEX "catalog_artifact_name_idx" ON "catalog_artifact" USING btree ("version","name");--> statement-breakpoint
CREATE INDEX "catalog_character_name_idx" ON "catalog_character" USING btree ("version","name");--> statement-breakpoint
CREATE INDEX "catalog_sync_status_idx" ON "catalog_sync_job" USING btree ("status","created_at");--> statement-breakpoint
CREATE UNIQUE INDEX "catalog_active_unique" ON "catalog_version" USING btree ("active") WHERE "catalog_version"."active" = true;--> statement-breakpoint
CREATE INDEX "catalog_weapon_name_idx" ON "catalog_weapon" USING btree ("version","name");--> statement-breakpoint
CREATE INDEX "extra_section_row_order_idx" ON "extra_section_row" USING btree ("section_id","sort_order");--> statement-breakpoint
CREATE UNIQUE INDEX "guide_section_slug_unique" ON "guide_section" USING btree ("guide_id","slug");--> statement-breakpoint
CREATE INDEX "guide_section_order_idx" ON "guide_section" USING btree ("guide_id","sort_order");--> statement-breakpoint
CREATE UNIQUE INDEX "guide_character_key_unique" ON "guide" USING btree ("character_key");--> statement-breakpoint
CREATE UNIQUE INDEX "guide_slug_unique" ON "guide" USING btree ("slug");--> statement-breakpoint
CREATE INDEX "guide_directory_idx" ON "guide" USING btree ("trashed_at","sort_order");--> statement-breakpoint
CREATE INDEX "team_composition_order_idx" ON "team_composition" USING btree ("guide_id","sort_order");--> statement-breakpoint
CREATE INDEX "weapon_recommendation_order_idx" ON "weapon_recommendation" USING btree ("guide_id","sort_order");
-- The structured guide launch intentionally resets legacy guide content while
-- preserving Better Auth users, accounts, sessions, and verification records.
DELETE FROM "character";
DELETE FROM "template";
DELETE FROM "data_source";
DELETE FROM "media_reference";
DELETE FROM "media";
DELETE FROM "outbox_event";