fix: rebuild migration history as baseline so migrate works on prod
Squash the 13 historical migrations into one generated baseline whose journal entry reuses the original 0000 timestamp: the migrator skips it on every existing database (prod journal stuck at 0006) and applies it only on fresh ones. Parity with the old chain verified via pg_dump diff plus fresh/existing/prod-simulated drizzle-kit migrate runs. Historical files move to drizzle-history/pre-squash-2026-08/ for integration tests that exercise legacy migration behavior. Also repair db tests that already failed before this change: - raw SQL targeted users, but the table has always been "user" - membership recheck mocked legacy getAsset.albums instead of searchPhotos - audit rollback assertion walks drizzle's wrapped error cause chain - keyset index probe pinned to NULLS LAST ordering, removing a planner cost tie-break that flipped with index creation order
This commit is contained in:
1 parent
2949149170
commit
0b65fbba16
40 files changed
+2389
-128
No files matched your search
@@ -2,14 +2,15 @@ CREATE TYPE "public"."portal_role" AS ENUM('ADMIN', 'EDITORIAL');--> statement-b
|
||||
CREATE TYPE "public"."report_status" AS ENUM('draft', 'final', 'cancelled');--> statement-breakpoint
|
||||
CREATE TYPE "public"."account_status" AS ENUM('pending_email', 'pending_approval', 'active', 'suspended', 'rejected');--> statement-breakpoint
|
||||
CREATE TYPE "public"."download_status" AS ENUM('authorized', 'streaming', 'completed', 'failed_before_delivery', 'interrupted');--> statement-breakpoint
|
||||
CREATE TYPE "public"."usage_billing_status" AS ENUM('open', 'billed', 'reopened');--> statement-breakpoint
|
||||
CREATE TYPE "public"."usage_billing_status" AS ENUM('open', 'billed', 'reopened', 'voided');--> statement-breakpoint
|
||||
CREATE TABLE "album_grants" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"editorial_account_id" uuid NOT NULL,
|
||||
"immich_album_id" text NOT NULL,
|
||||
"granted_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"revoked_at" timestamp with time zone,
|
||||
"granted_by_user_id" uuid
|
||||
"granted_by_user_id" uuid,
|
||||
CONSTRAINT "album_grants_immich_album_id_uuid_check" CHECK ("album_grants"."immich_album_id" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$')
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "audit_events" (
|
||||
@@ -53,6 +54,17 @@ CREATE TABLE "session" (
|
||||
CONSTRAINT "session_token_unique" UNIQUE("token")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "two_factor" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"secret" text NOT NULL,
|
||||
"backup_codes" text,
|
||||
"verified" boolean DEFAULT false NOT NULL,
|
||||
"failed_verification_count" integer DEFAULT 0 NOT NULL,
|
||||
"locked_until" timestamp with time zone,
|
||||
CONSTRAINT "two_factor_user_id_unique" UNIQUE("user_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "user" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
@@ -60,6 +72,7 @@ CREATE TABLE "user" (
|
||||
"email_verified" boolean DEFAULT false NOT NULL,
|
||||
"image" text,
|
||||
"role" "portal_role" DEFAULT 'EDITORIAL' NOT NULL,
|
||||
"two_factor_enabled" boolean DEFAULT false NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "user_email_unique" UNIQUE("email")
|
||||
@@ -74,6 +87,14 @@ CREATE TABLE "verification" (
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "album_auto_rules" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"editorial_account_id" uuid NOT NULL,
|
||||
"keyword" text NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"created_by_user_id" uuid
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "billing_report_items" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"billing_report_id" uuid NOT NULL,
|
||||
@@ -96,6 +117,7 @@ CREATE TABLE "billing_reports" (
|
||||
"billing_address_snapshot" jsonb NOT NULL,
|
||||
"invoice_number" text,
|
||||
"net_total_cents" integer NOT NULL,
|
||||
"flatrate_cents_snapshot" integer,
|
||||
"status" "report_status" DEFAULT 'draft' NOT NULL,
|
||||
"pdf" "bytea",
|
||||
"pdf_sha256" varchar(64),
|
||||
@@ -133,17 +155,39 @@ CREATE TABLE "editorial_accounts" (
|
||||
"login_email" text NOT NULL,
|
||||
"status" "account_status" DEFAULT 'pending_email' NOT NULL,
|
||||
"current_price_cents" integer,
|
||||
"flatrate_active" boolean DEFAULT false NOT NULL,
|
||||
"flatrate_price_cents" integer,
|
||||
"flatrate_asset_limit" integer,
|
||||
"approval_notice_status" text DEFAULT 'not_requested' NOT NULL,
|
||||
"current_billing_address_version_id" uuid,
|
||||
"email_verified_at" timestamp with time zone,
|
||||
"accepted_terms_version" text,
|
||||
"accepted_terms_at" timestamp with time zone,
|
||||
"privacy_acknowledged_at" timestamp with time zone,
|
||||
"archived_at" timestamp with time zone,
|
||||
"archived_by_user_id" uuid,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "editorial_accounts_user_id_unique" UNIQUE("user_id"),
|
||||
CONSTRAINT "editorial_accounts_login_email_unique" UNIQUE("login_email")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "lightbox_items" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"editorial_account_id" uuid NOT NULL,
|
||||
"asset_id" text NOT NULL,
|
||||
"added_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "rate_limits" (
|
||||
"key" text NOT NULL,
|
||||
"window_boundary" integer NOT NULL,
|
||||
"count" integer DEFAULT 1 NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "rate_limits_key_window_boundary_pk" PRIMARY KEY("key","window_boundary")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "download_events" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"editorial_account_id" uuid NOT NULL,
|
||||
@@ -156,7 +200,14 @@ CREATE TABLE "download_events" (
|
||||
"transferred_bytes" bigint,
|
||||
"repeat_download_note" text,
|
||||
"request_id" uuid NOT NULL,
|
||||
"idempotency_key" text NOT NULL
|
||||
"idempotency_key" text NOT NULL,
|
||||
"intent_kind" text DEFAULT 'new_usage' NOT NULL,
|
||||
"request_fingerprint" varchar(64) NOT NULL,
|
||||
"legacy_intent" boolean DEFAULT false NOT NULL,
|
||||
CONSTRAINT "download_events_intent_kind_check" CHECK ("download_events"."intent_kind" in ('new_usage', 'repeat_download', 'legacy')),
|
||||
CONSTRAINT "download_events_request_fingerprint_hex_check" CHECK ("download_events"."request_fingerprint" ~ '^[0-9a-f]{64}$'),
|
||||
CONSTRAINT "download_events_canonical_idempotency_key_check" CHECK ("download_events"."legacy_intent" OR "download_events"."idempotency_key" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'),
|
||||
CONSTRAINT "download_events_canonical_immich_asset_id_check" CHECK ("download_events"."immich_asset_id" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$')
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "usages" (
|
||||
@@ -171,7 +222,9 @@ CREATE TABLE "usages" (
|
||||
"price_cents" integer NOT NULL,
|
||||
"billing_status" "usage_billing_status" DEFAULT 'open' NOT NULL,
|
||||
"billing_report_id" uuid,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "usages_canonical_immich_asset_id_check" CHECK ("usages"."immich_asset_id" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'),
|
||||
CONSTRAINT "usages_canonical_immich_album_id_check" CHECK ("usages"."immich_album_id_snapshot" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$')
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "album_grants" ADD CONSTRAINT "album_grants_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
@@ -179,6 +232,9 @@ ALTER TABLE "album_grants" ADD CONSTRAINT "album_grants_granted_by_user_id_user_
|
||||
ALTER TABLE "audit_events" ADD CONSTRAINT "audit_events_actor_user_id_user_id_fk" FOREIGN KEY ("actor_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "two_factor" ADD CONSTRAINT "two_factor_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "album_auto_rules" ADD CONSTRAINT "album_auto_rules_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "album_auto_rules" ADD CONSTRAINT "album_auto_rules_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "billing_report_items" ADD CONSTRAINT "billing_report_items_billing_report_id_billing_reports_id_fk" FOREIGN KEY ("billing_report_id") REFERENCES "public"."billing_reports"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "billing_report_items" ADD CONSTRAINT "billing_report_items_usage_id_usages_id_fk" FOREIGN KEY ("usage_id") REFERENCES "public"."usages"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "billing_reports" ADD CONSTRAINT "billing_reports_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
@@ -189,13 +245,21 @@ ALTER TABLE "billing_address_versions" ADD CONSTRAINT "billing_address_versions_
|
||||
ALTER TABLE "billing_address_versions" ADD CONSTRAINT "billing_address_versions_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "editorial_accounts" ADD CONSTRAINT "editorial_accounts_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "editorial_accounts" ADD CONSTRAINT "editorial_accounts_current_billing_address_version_id_billing_address_versions_id_fk" FOREIGN KEY ("current_billing_address_version_id") REFERENCES "public"."billing_address_versions"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "editorial_accounts" ADD CONSTRAINT "editorial_accounts_archived_by_user_id_user_id_fk" FOREIGN KEY ("archived_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "lightbox_items" ADD CONSTRAINT "lightbox_items_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ADD CONSTRAINT "download_events_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ADD CONSTRAINT "download_events_usage_id_usages_id_fk" FOREIGN KEY ("usage_id") REFERENCES "public"."usages"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "usages" ADD CONSTRAINT "usages_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "usages" ADD CONSTRAINT "usages_billing_report_id_billing_reports_id_fk" FOREIGN KEY ("billing_report_id") REFERENCES "public"."billing_reports"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE INDEX "album_grants_editorial_account_id_idx" ON "album_grants" USING btree ("editorial_account_id");--> statement-breakpoint
|
||||
CREATE INDEX "album_grants_immich_album_id_idx" ON "album_grants" USING btree ("immich_album_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "album_grants_editorial_active_album_unique" ON "album_grants" USING btree ("editorial_account_id",lower("immich_album_id")) WHERE "album_grants"."revoked_at" is null;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "album_auto_rules_editorial_account_id_keyword_idx" ON "album_auto_rules" USING btree ("editorial_account_id",lower("keyword"));--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "billing_report_items_report_usage_unique" ON "billing_report_items" USING btree ("billing_report_id","usage_id");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "billing_reports_report_number_unique" ON "billing_reports" USING btree ("report_number");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "billing_reports_invoice_number_unique" ON "billing_reports" USING btree ("invoice_number");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "download_events_editorial_idempotency_key_unique" ON "download_events" USING btree ("editorial_account_id","idempotency_key");
|
||||
CREATE UNIQUE INDEX "lightbox_items_editorial_asset_idx" ON "lightbox_items" USING btree ("editorial_account_id","asset_id");--> statement-breakpoint
|
||||
CREATE INDEX "download_events_editorial_authorized_id_idx" ON "download_events" USING btree ("editorial_account_id","authorized_at" DESC NULLS LAST,"id" DESC NULLS LAST);--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "download_events_editorial_idempotency_key_unique" ON "download_events" USING btree ("editorial_account_id","idempotency_key");--> statement-breakpoint
|
||||
CREATE INDEX "usages_editorial_created_id_idx" ON "usages" USING btree ("editorial_account_id","created_at" DESC NULLS LAST,"id" DESC NULLS LAST);--> statement-breakpoint
|
||||
CREATE INDEX "usages_created_at_idx" ON "usages" USING btree ("created_at");
|
||||
@@ -1 +0,0 @@
|
||||
ALTER TABLE "editorial_accounts" ADD COLUMN "approval_notice_status" text DEFAULT 'not_requested' NOT NULL;
|
||||
@@ -1,186 +0,0 @@
|
||||
ALTER TABLE "download_events" ADD COLUMN "intent_kind" text;--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ADD COLUMN "request_fingerprint" varchar(64);--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ADD COLUMN "legacy_intent" boolean;--> statement-breakpoint
|
||||
-- UUID-shaped legacy keys are canonicalized only when doing so is unambiguous.
|
||||
-- Arbitrary and case-colliding historical keys remain byte-for-byte unchanged.
|
||||
WITH case_colliding_idempotency_keys AS (
|
||||
SELECT "editorial_account_id", lower("idempotency_key") AS canonical_key
|
||||
FROM "download_events"
|
||||
GROUP BY "editorial_account_id", lower("idempotency_key")
|
||||
HAVING count(*) > 1
|
||||
)
|
||||
UPDATE "download_events" AS target
|
||||
SET "idempotency_key" = lower(target."idempotency_key")
|
||||
WHERE
|
||||
target."idempotency_key" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM case_colliding_idempotency_keys AS collision
|
||||
WHERE
|
||||
collision."editorial_account_id" = target."editorial_account_id"
|
||||
AND collision.canonical_key = lower(target."idempotency_key")
|
||||
);--> statement-breakpoint
|
||||
-- A legacy new usage is reconstructible only when it has one unique earliest,
|
||||
-- note-free event and every runtime fingerprint field already satisfies the new
|
||||
-- normalized input contract. A repeat additionally needs a normalized non-null
|
||||
-- repeat note after that provable initial event. Every other row is explicit legacy.
|
||||
WITH earliest_event_times AS (
|
||||
SELECT "usage_id", min("authorized_at") AS earliest_authorized_at
|
||||
FROM "download_events"
|
||||
GROUP BY "usage_id"
|
||||
),
|
||||
case_colliding_idempotency_keys AS (
|
||||
SELECT "editorial_account_id", lower("idempotency_key") AS canonical_key
|
||||
FROM "download_events"
|
||||
GROUP BY "editorial_account_id", lower("idempotency_key")
|
||||
HAVING count(*) > 1
|
||||
),
|
||||
legacy_event_candidates AS (
|
||||
SELECT
|
||||
events."id",
|
||||
events."usage_id",
|
||||
events."authorized_at",
|
||||
earliest.earliest_authorized_at,
|
||||
(
|
||||
events."repeat_download_note" IS NULL
|
||||
AND events."editorial_account_id" = usage."editorial_account_id"
|
||||
AND lower(events."immich_asset_id") = lower(usage."immich_asset_id")
|
||||
AND events."immich_asset_id" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
|
||||
AND usage."immich_asset_id" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
|
||||
AND usage."immich_album_id_snapshot" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
|
||||
AND events."idempotency_key" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
|
||||
AND octet_length(usage."purpose") = char_length(usage."purpose")
|
||||
AND usage."purpose" !~ '[[:cntrl:]]'
|
||||
AND left(usage."purpose", 1) <> ' '
|
||||
AND right(usage."purpose", 1) <> ' '
|
||||
AND char_length(usage."purpose") BETWEEN 3 AND 200
|
||||
AND (
|
||||
usage."internal_reference" IS NULL
|
||||
OR (
|
||||
octet_length(usage."internal_reference") = char_length(usage."internal_reference")
|
||||
AND usage."internal_reference" !~ '[[:cntrl:]]'
|
||||
AND left(usage."internal_reference", 1) <> ' '
|
||||
AND right(usage."internal_reference", 1) <> ' '
|
||||
AND usage."internal_reference" <> ''
|
||||
AND char_length(usage."internal_reference") <= 200
|
||||
)
|
||||
)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM case_colliding_idempotency_keys AS collision
|
||||
WHERE
|
||||
collision."editorial_account_id" = events."editorial_account_id"
|
||||
AND collision.canonical_key = lower(events."idempotency_key")
|
||||
)
|
||||
) AS can_be_initial,
|
||||
(
|
||||
events."editorial_account_id" = usage."editorial_account_id"
|
||||
AND lower(events."immich_asset_id") = lower(usage."immich_asset_id")
|
||||
AND events."immich_asset_id" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
|
||||
AND events."idempotency_key" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'
|
||||
AND octet_length(events."repeat_download_note") = char_length(events."repeat_download_note")
|
||||
AND events."repeat_download_note" !~ '[[:cntrl:]]'
|
||||
AND left(events."repeat_download_note", 1) <> ' '
|
||||
AND right(events."repeat_download_note", 1) <> ' '
|
||||
AND events."repeat_download_note" <> ''
|
||||
AND char_length(events."repeat_download_note") <= 200
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM case_colliding_idempotency_keys AS collision
|
||||
WHERE
|
||||
collision."editorial_account_id" = events."editorial_account_id"
|
||||
AND collision.canonical_key = lower(events."idempotency_key")
|
||||
)
|
||||
) AS can_be_repeat
|
||||
FROM "download_events" AS events
|
||||
INNER JOIN "usages" AS usage ON usage."id" = events."usage_id"
|
||||
INNER JOIN earliest_event_times AS earliest ON earliest."usage_id" = events."usage_id"
|
||||
),
|
||||
usage_event_summary AS (
|
||||
SELECT
|
||||
candidate."usage_id",
|
||||
candidate.earliest_authorized_at,
|
||||
count(*) FILTER (
|
||||
WHERE candidate."authorized_at" = candidate.earliest_authorized_at
|
||||
) AS earliest_event_count,
|
||||
bool_and(
|
||||
CASE
|
||||
WHEN candidate."authorized_at" = candidate.earliest_authorized_at
|
||||
THEN candidate.can_be_initial
|
||||
ELSE true
|
||||
END
|
||||
) AS earliest_event_is_provable
|
||||
FROM legacy_event_candidates AS candidate
|
||||
GROUP BY candidate."usage_id", candidate.earliest_authorized_at
|
||||
)
|
||||
UPDATE "download_events" AS events
|
||||
SET "intent_kind" = CASE
|
||||
WHEN
|
||||
candidate."authorized_at" = summary.earliest_authorized_at
|
||||
AND summary.earliest_event_count = 1
|
||||
AND candidate.can_be_initial
|
||||
THEN 'new_usage'
|
||||
WHEN
|
||||
candidate."authorized_at" > summary.earliest_authorized_at
|
||||
AND summary.earliest_event_count = 1
|
||||
AND summary.earliest_event_is_provable
|
||||
AND candidate.can_be_repeat
|
||||
THEN 'repeat_download'
|
||||
ELSE 'legacy'
|
||||
END
|
||||
FROM legacy_event_candidates AS candidate, usage_event_summary AS summary
|
||||
WHERE
|
||||
candidate."id" = events."id"
|
||||
AND summary."usage_id" = candidate."usage_id";--> statement-breakpoint
|
||||
-- Runtime-compatible rows receive the exact SHA-256 used by JSON.stringify in the
|
||||
-- application. Explicit legacy rows receive a deterministic non-runtime hash.
|
||||
UPDATE "download_events" AS events
|
||||
SET "request_fingerprint" = CASE
|
||||
WHEN events."intent_kind" = 'new_usage' THEN encode(sha256(convert_to(
|
||||
'{"kind":"new_usage","editorialId":' || to_json(events."editorial_account_id"::text)::text ||
|
||||
',"assetId":' || to_json(lower(events."immich_asset_id"))::text ||
|
||||
',"albumId":' || to_json(lower(usage."immich_album_id_snapshot"))::text ||
|
||||
',"purpose":' || to_json(usage."purpose")::text ||
|
||||
',"reference":' || coalesce(to_json(usage."internal_reference")::text, 'null') ||
|
||||
'}',
|
||||
'UTF8'
|
||||
)), 'hex')
|
||||
WHEN events."intent_kind" = 'repeat_download' THEN encode(sha256(convert_to(
|
||||
'{"kind":"repeat_download","editorialId":' || to_json(events."editorial_account_id"::text)::text ||
|
||||
',"usageId":' || to_json(events."usage_id"::text)::text ||
|
||||
',"note":' || to_json(events."repeat_download_note")::text ||
|
||||
'}',
|
||||
'UTF8'
|
||||
)), 'hex')
|
||||
ELSE encode(sha256(convert_to('legacy-intent-v1:' || events."id"::text, 'UTF8')), 'hex')
|
||||
END
|
||||
FROM "usages" AS usage
|
||||
WHERE usage."id" = events."usage_id";--> statement-breakpoint
|
||||
UPDATE "download_events" SET "legacy_intent" = true;--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ALTER COLUMN "intent_kind" SET DEFAULT 'new_usage';--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ALTER COLUMN "intent_kind" SET NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ALTER COLUMN "request_fingerprint" SET NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ALTER COLUMN "legacy_intent" SET DEFAULT false;--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ALTER COLUMN "legacy_intent" SET NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ADD CONSTRAINT "download_events_intent_kind_check" CHECK ("download_events"."intent_kind" in ('new_usage', 'repeat_download', 'legacy'));--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ADD CONSTRAINT "download_events_request_fingerprint_hex_check" CHECK ("download_events"."request_fingerprint" ~ '^[0-9a-f]{64}$');--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ADD CONSTRAINT "download_events_canonical_idempotency_key_check" CHECK ("download_events"."legacy_intent" OR "download_events"."idempotency_key" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$');--> statement-breakpoint
|
||||
WITH ranked_active_album_grants AS (
|
||||
SELECT
|
||||
"id",
|
||||
row_number() OVER (
|
||||
PARTITION BY "editorial_account_id", lower("immich_album_id")
|
||||
ORDER BY ("immich_album_id" = lower("immich_album_id")) DESC, "granted_at", "id"
|
||||
) AS survivor_order
|
||||
FROM "album_grants"
|
||||
WHERE "revoked_at" IS NULL
|
||||
)
|
||||
UPDATE "album_grants" AS grants
|
||||
SET "revoked_at" = now()
|
||||
FROM ranked_active_album_grants AS ranked
|
||||
WHERE grants."id" = ranked."id" AND ranked.survivor_order > 1;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "album_grants_editorial_active_album_unique" ON "album_grants" ("editorial_account_id", lower("immich_album_id")) WHERE "revoked_at" IS NULL;--> statement-breakpoint
|
||||
ALTER TABLE "album_grants" ADD CONSTRAINT "album_grants_immich_album_id_uuid_check" CHECK ("album_grants"."immich_album_id" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$') NOT VALID;--> statement-breakpoint
|
||||
ALTER TABLE "download_events" ADD CONSTRAINT "download_events_canonical_immich_asset_id_check" CHECK ("download_events"."immich_asset_id" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$') NOT VALID;--> statement-breakpoint
|
||||
ALTER TABLE "usages" ADD CONSTRAINT "usages_canonical_immich_asset_id_check" CHECK ("usages"."immich_asset_id" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$') NOT VALID;--> statement-breakpoint
|
||||
ALTER TABLE "usages" ADD CONSTRAINT "usages_canonical_immich_album_id_check" CHECK ("usages"."immich_album_id_snapshot" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$') NOT VALID;
|
||||
@@ -1 +0,0 @@
|
||||
ALTER TYPE "public"."usage_billing_status" ADD VALUE 'voided';
|
||||
@@ -1,2 +0,0 @@
|
||||
CREATE INDEX "download_events_editorial_authorized_id_idx" ON "download_events" USING btree ("editorial_account_id","authorized_at" DESC NULLS LAST,"id" DESC NULLS LAST);--> statement-breakpoint
|
||||
CREATE INDEX "usages_editorial_created_id_idx" ON "usages" USING btree ("editorial_account_id","created_at" DESC NULLS LAST,"id" DESC NULLS LAST);
|
||||
@@ -1,8 +0,0 @@
|
||||
CREATE TABLE "rate_limits" (
|
||||
"key" text NOT NULL,
|
||||
"window_boundary" integer NOT NULL,
|
||||
"count" integer DEFAULT 1 NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "rate_limits_key_window_boundary_pk" PRIMARY KEY("key","window_boundary")
|
||||
);
|
||||
@@ -1,14 +0,0 @@
|
||||
CREATE TABLE "album_auto_rules" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"editorial_account_id" uuid NOT NULL,
|
||||
"keyword" text NOT NULL,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"created_by_user_id" uuid
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "editorial_accounts" ADD COLUMN "archived_at" timestamp with time zone;--> statement-breakpoint
|
||||
ALTER TABLE "editorial_accounts" ADD COLUMN "archived_by_user_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "album_auto_rules" ADD CONSTRAINT "album_auto_rules_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "album_auto_rules" ADD CONSTRAINT "album_auto_rules_created_by_user_id_user_id_fk" FOREIGN KEY ("created_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "album_auto_rules_editorial_account_id_keyword_idx" ON "album_auto_rules" USING btree ("editorial_account_id",lower("keyword"));--> statement-breakpoint
|
||||
ALTER TABLE "editorial_accounts" ADD CONSTRAINT "editorial_accounts_archived_by_user_id_user_id_fk" FOREIGN KEY ("archived_by_user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;
|
||||
@@ -1,9 +0,0 @@
|
||||
CREATE TABLE "lightbox_items" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"editorial_account_id" uuid NOT NULL,
|
||||
"asset_id" text NOT NULL,
|
||||
"added_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "lightbox_items" ADD CONSTRAINT "lightbox_items_editorial_account_id_editorial_accounts_id_fk" FOREIGN KEY ("editorial_account_id") REFERENCES "public"."editorial_accounts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "lightbox_items_editorial_asset_idx" ON "lightbox_items" USING btree ("editorial_account_id","asset_id");
|
||||
@@ -1,4 +0,0 @@
|
||||
ALTER TABLE "billing_reports" ADD COLUMN "flatrate_cents_snapshot" integer;--> statement-breakpoint
|
||||
ALTER TABLE "editorial_accounts" ADD COLUMN "flatrate_active" boolean DEFAULT false NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "editorial_accounts" ADD COLUMN "flatrate_price_cents" integer;--> statement-breakpoint
|
||||
ALTER TABLE "editorial_accounts" ADD COLUMN "flatrate_asset_limit" integer;
|
||||
@@ -1 +0,0 @@
|
||||
CREATE INDEX "usages_created_at_idx" ON "usages" USING btree ("created_at");
|
||||
@@ -1,10 +0,0 @@
|
||||
CREATE TABLE "two_factor" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"user_id" uuid NOT NULL,
|
||||
"secret" text NOT NULL,
|
||||
"backup_codes" text,
|
||||
CONSTRAINT "two_factor_user_id_unique" UNIQUE("user_id")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "user" ADD COLUMN "two_factor_enabled" boolean DEFAULT false NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "two_factor" ADD CONSTRAINT "two_factor_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE restrict ON UPDATE no action;
|
||||
@@ -1 +0,0 @@
|
||||
ALTER TABLE "two_factor" ADD COLUMN "verified" boolean DEFAULT false NOT NULL;
|
||||
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE "two_factor" ADD COLUMN "failed_verification_count" integer DEFAULT 0 NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "two_factor" ADD COLUMN "locked_until" timestamp with time zone;
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"id": "64eb37ed-2ab5-4c12-a8be-4375e8f6a732",
|
||||
"id": "5ac645f2-0e76-4853-b029-724095bf1138",
|
||||
"prevId": "00000000-0000-0000-0000-000000000000",
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
@@ -77,6 +77,28 @@
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"album_grants_editorial_active_album_unique": {
|
||||
"name": "album_grants_editorial_active_album_unique",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "editorial_account_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "lower(\"immich_album_id\")",
|
||||
"asc": true,
|
||||
"isExpression": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"where": "\"album_grants\".\"revoked_at\" is null",
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
@@ -110,7 +132,12 @@
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"checkConstraints": {
|
||||
"album_grants_immich_album_id_uuid_check": {
|
||||
"name": "album_grants_immich_album_id_uuid_check",
|
||||
"value": "\"album_grants\".\"immich_album_id\" ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
|
||||
}
|
||||
},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.audit_events": {
|
||||
@@ -397,6 +424,86 @@
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.two_factor": {
|
||||
"name": "two_factor",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"secret": {
|
||||
"name": "secret",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"backup_codes": {
|
||||
"name": "backup_codes",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"verified": {
|
||||
"name": "verified",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": false
|
||||
},
|
||||
"failed_verification_count": {
|
||||
"name": "failed_verification_count",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 0
|
||||
},
|
||||
"locked_until": {
|
||||
"name": "locked_until",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {
|
||||
"two_factor_user_id_user_id_fk": {
|
||||
"name": "two_factor_user_id_user_id_fk",
|
||||
"tableFrom": "two_factor",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "restrict",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {
|
||||
"two_factor_user_id_unique": {
|
||||
"name": "two_factor_user_id_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"user_id"
|
||||
]
|
||||
}
|
||||
},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.user": {
|
||||
"name": "user",
|
||||
"schema": "",
|
||||
@@ -441,6 +548,13 @@
|
||||
"notNull": true,
|
||||
"default": "'EDITORIAL'"
|
||||
},
|
||||
"two_factor_enabled": {
|
||||
"name": "two_factor_enabled",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp with time zone",
|
||||
@@ -524,6 +638,100 @@
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.album_auto_rules": {
|
||||
"name": "album_auto_rules",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"editorial_account_id": {
|
||||
"name": "editorial_account_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"keyword": {
|
||||
"name": "keyword",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"created_by_user_id": {
|
||||
"name": "created_by_user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"album_auto_rules_editorial_account_id_keyword_idx": {
|
||||
"name": "album_auto_rules_editorial_account_id_keyword_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "editorial_account_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "lower(\"keyword\")",
|
||||
"asc": true,
|
||||
"isExpression": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"album_auto_rules_editorial_account_id_editorial_accounts_id_fk": {
|
||||
"name": "album_auto_rules_editorial_account_id_editorial_accounts_id_fk",
|
||||
"tableFrom": "album_auto_rules",
|
||||
"tableTo": "editorial_accounts",
|
||||
"columnsFrom": [
|
||||
"editorial_account_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "restrict",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"album_auto_rules_created_by_user_id_user_id_fk": {
|
||||
"name": "album_auto_rules_created_by_user_id_user_id_fk",
|
||||
"tableFrom": "album_auto_rules",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"created_by_user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "restrict",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.billing_report_items": {
|
||||
"name": "billing_report_items",
|
||||
"schema": "",
|
||||
@@ -701,6 +909,12 @@
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"flatrate_cents_snapshot": {
|
||||
"name": "flatrate_cents_snapshot",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"status": {
|
||||
"name": "status",
|
||||
"type": "report_status",
|
||||
@@ -1030,6 +1244,32 @@
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"flatrate_active": {
|
||||
"name": "flatrate_active",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": false
|
||||
},
|
||||
"flatrate_price_cents": {
|
||||
"name": "flatrate_price_cents",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"flatrate_asset_limit": {
|
||||
"name": "flatrate_asset_limit",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"approval_notice_status": {
|
||||
"name": "approval_notice_status",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'not_requested'"
|
||||
},
|
||||
"current_billing_address_version_id": {
|
||||
"name": "current_billing_address_version_id",
|
||||
"type": "uuid",
|
||||
@@ -1060,6 +1300,18 @@
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"archived_at": {
|
||||
"name": "archived_at",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"archived_by_user_id": {
|
||||
"name": "archived_by_user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp with time zone",
|
||||
@@ -1102,6 +1354,19 @@
|
||||
],
|
||||
"onDelete": "restrict",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"editorial_accounts_archived_by_user_id_user_id_fk": {
|
||||
"name": "editorial_accounts_archived_by_user_id_user_id_fk",
|
||||
"tableFrom": "editorial_accounts",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"archived_by_user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "restrict",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
@@ -1125,6 +1390,135 @@
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.lightbox_items": {
|
||||
"name": "lightbox_items",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"editorial_account_id": {
|
||||
"name": "editorial_account_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"asset_id": {
|
||||
"name": "asset_id",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"added_at": {
|
||||
"name": "added_at",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"lightbox_items_editorial_asset_idx": {
|
||||
"name": "lightbox_items_editorial_asset_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "editorial_account_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "asset_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"lightbox_items_editorial_account_id_editorial_accounts_id_fk": {
|
||||
"name": "lightbox_items_editorial_account_id_editorial_accounts_id_fk",
|
||||
"tableFrom": "lightbox_items",
|
||||
"tableTo": "editorial_accounts",
|
||||
"columnsFrom": [
|
||||
"editorial_account_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.rate_limits": {
|
||||
"name": "rate_limits",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"key": {
|
||||
"name": "key",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"window_boundary": {
|
||||
"name": "window_boundary",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"count": {
|
||||
"name": "count",
|
||||
"type": "integer",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": 1
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
},
|
||||
"updated_at": {
|
||||
"name": "updated_at",
|
||||
"type": "timestamp with time zone",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {
|
||||
"rate_limits_key_window_boundary_pk": {
|
||||
"name": "rate_limits_key_window_boundary_pk",
|
||||
"columns": [
|
||||
"key",
|
||||
"window_boundary"
|
||||
]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.download_events": {
|
||||
"name": "download_events",
|
||||
"schema": "",
|
||||
@@ -1204,9 +1598,56 @@
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"intent_kind": {
|
||||
"name": "intent_kind",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'new_usage'"
|
||||
},
|
||||
"request_fingerprint": {
|
||||
"name": "request_fingerprint",
|
||||
"type": "varchar(64)",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"legacy_intent": {
|
||||
"name": "legacy_intent",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"download_events_editorial_authorized_id_idx": {
|
||||
"name": "download_events_editorial_authorized_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "editorial_account_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "authorized_at",
|
||||
"isExpression": false,
|
||||
"asc": false,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "id",
|
||||
"isExpression": false,
|
||||
"asc": false,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"download_events_editorial_idempotency_key_unique": {
|
||||
"name": "download_events_editorial_idempotency_key_unique",
|
||||
"columns": [
|
||||
@@ -1260,7 +1701,24 @@
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"checkConstraints": {
|
||||
"download_events_intent_kind_check": {
|
||||
"name": "download_events_intent_kind_check",
|
||||
"value": "\"download_events\".\"intent_kind\" in ('new_usage', 'repeat_download', 'legacy')"
|
||||
},
|
||||
"download_events_request_fingerprint_hex_check": {
|
||||
"name": "download_events_request_fingerprint_hex_check",
|
||||
"value": "\"download_events\".\"request_fingerprint\" ~ '^[0-9a-f]{64}$'"
|
||||
},
|
||||
"download_events_canonical_idempotency_key_check": {
|
||||
"name": "download_events_canonical_idempotency_key_check",
|
||||
"value": "\"download_events\".\"legacy_intent\" OR \"download_events\".\"idempotency_key\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
|
||||
},
|
||||
"download_events_canonical_immich_asset_id_check": {
|
||||
"name": "download_events_canonical_immich_asset_id_check",
|
||||
"value": "\"download_events\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
|
||||
}
|
||||
},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.usages": {
|
||||
@@ -1344,7 +1802,50 @@
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"indexes": {
|
||||
"usages_editorial_created_id_idx": {
|
||||
"name": "usages_editorial_created_id_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "editorial_account_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "created_at",
|
||||
"isExpression": false,
|
||||
"asc": false,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "id",
|
||||
"isExpression": false,
|
||||
"asc": false,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
},
|
||||
"usages_created_at_idx": {
|
||||
"name": "usages_created_at_idx",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "created_at",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": false,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"usages_editorial_account_id_editorial_accounts_id_fk": {
|
||||
"name": "usages_editorial_account_id_editorial_accounts_id_fk",
|
||||
@@ -1376,7 +1877,16 @@
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"checkConstraints": {
|
||||
"usages_canonical_immich_asset_id_check": {
|
||||
"name": "usages_canonical_immich_asset_id_check",
|
||||
"value": "\"usages\".\"immich_asset_id\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
|
||||
},
|
||||
"usages_canonical_immich_album_id_check": {
|
||||
"name": "usages_canonical_immich_album_id_check",
|
||||
"value": "\"usages\".\"immich_album_id_snapshot\" ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'"
|
||||
}
|
||||
},
|
||||
"isRLSEnabled": false
|
||||
}
|
||||
},
|
||||
@@ -1426,7 +1936,8 @@
|
||||
"values": [
|
||||
"open",
|
||||
"billed",
|
||||
"reopened"
|
||||
"reopened",
|
||||
"voided"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -6,92 +6,8 @@
|
||||
"idx": 0,
|
||||
"version": "7",
|
||||
"when": 1786299825190,
|
||||
"tag": "0000_initial",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 1,
|
||||
"version": "7",
|
||||
"when": 1786303607054,
|
||||
"tag": "0001_editorial_approval_notice",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 2,
|
||||
"version": "7",
|
||||
"when": 1786354215684,
|
||||
"tag": "0002_accounting_intents",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 3,
|
||||
"version": "7",
|
||||
"when": 1786358492749,
|
||||
"tag": "0003_stream_delivery",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 4,
|
||||
"version": "7",
|
||||
"when": 1786363479515,
|
||||
"tag": "0004_download_history_indexes",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 5,
|
||||
"version": "7",
|
||||
"when": 1786379282947,
|
||||
"tag": "0005_rate_limits",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 6,
|
||||
"version": "7",
|
||||
"when": 1786410282719,
|
||||
"tag": "0006_chubby_screwball",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 7,
|
||||
"version": "7",
|
||||
"when": 1786410724623,
|
||||
"tag": "0007_amused_franklin_storm",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 8,
|
||||
"version": "7",
|
||||
"when": 1786411419497,
|
||||
"tag": "0008_overjoyed_wrecking_crew",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 9,
|
||||
"version": "7",
|
||||
"when": 1786455754414,
|
||||
"tag": "0009_usage_created_at_index",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 10,
|
||||
"version": "7",
|
||||
"when": 1787617368189,
|
||||
"tag": "0010_two-factor",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 11,
|
||||
"version": "7",
|
||||
"when": 1787620365940,
|
||||
"tag": "0011_two-factor-verified",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 12,
|
||||
"version": "7",
|
||||
"when": 1787621254728,
|
||||
"tag": "0012_two-factor-plugin-fields",
|
||||
"tag": "0000_baseline",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user