@meith/db 0.33.4 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ CREATE TABLE "backup_runs" (
2
+ "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "backup_runs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
3
+ "trigger" text NOT NULL,
4
+ "status" text DEFAULT 'queued' NOT NULL,
5
+ "requested_by_user_id" integer,
6
+ "requested_at" timestamp with time zone DEFAULT now() NOT NULL,
7
+ "started_at" timestamp with time zone,
8
+ "finished_at" timestamp with time zone,
9
+ "heartbeat_at" timestamp with time zone,
10
+ "bundle_name" text,
11
+ "size_bytes" bigint,
12
+ "uploads" text,
13
+ "shipped" boolean DEFAULT false NOT NULL,
14
+ "skipped_keys" integer DEFAULT 0 NOT NULL,
15
+ "error" text,
16
+ CONSTRAINT "backup_runs_trigger_check" CHECK ("backup_runs"."trigger" in ('manual', 'schedule', 'upgrade', 'cli')),
17
+ CONSTRAINT "backup_runs_status_check" CHECK ("backup_runs"."status" in ('queued', 'running', 'done', 'incomplete', 'failed'))
18
+ );
19
+ --> statement-breakpoint
20
+ ALTER TABLE "backup_runs" ADD CONSTRAINT "backup_runs_requested_by_user_id_users_id_fk" FOREIGN KEY ("requested_by_user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
21
+ CREATE INDEX "backup_runs_status_idx" ON "backup_runs" USING btree ("status","id");--> statement-breakpoint
22
+ CREATE INDEX "backup_runs_recent_idx" ON "backup_runs" USING btree ("requested_at" DESC NULLS LAST);
@@ -0,0 +1 @@
1
+ CREATE UNIQUE INDEX "backup_runs_active_idx" ON "backup_runs" USING btree ("status") WHERE "backup_runs"."status" in ('queued', 'running');