@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.
- package/migrations/0068_backup_runs.sql +22 -0
- package/migrations/0069_backup_runs_active.sql +1 -0
- package/migrations/meta/0068_snapshot.json +9864 -0
- package/migrations/meta/0069_snapshot.json +9880 -0
- package/migrations/meta/_journal.json +14 -0
- package/package.json +32 -31
- package/src/backup-run-repo.ts +212 -0
- package/src/index.ts +7 -1
- package/src/schema/platform.ts +39 -0
- package/src/settings-repo.ts +64 -4
- package/src/system-health-repo.ts +2 -1
- package/src/task-repo.ts +14 -0
- package/src/user-merge-map.ts +1 -0
|
@@ -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');
|