Add prepared tenant export archives

This commit is contained in:
2026-07-05 12:25:39 +02:00
parent 033e74adda
commit 0a7b0448ad
6 changed files with 601 additions and 19 deletions

View File

@@ -0,0 +1,19 @@
CREATE TABLE IF NOT EXISTS "tenant_export_jobs" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
"updated_at" timestamp with time zone,
"completed_at" timestamp with time zone,
"tenant_id" bigint NOT NULL REFERENCES "tenants"("id") ON DELETE cascade,
"created_by" uuid REFERENCES "auth_users"("id"),
"status" text DEFAULT 'queued' NOT NULL,
"filename" text NOT NULL,
"storage_path" text,
"content_type" text DEFAULT 'application/zip' NOT NULL,
"file_size" bigint,
"error" text,
"files_total" integer DEFAULT 0 NOT NULL,
"files_done" integer DEFAULT 0 NOT NULL
);
CREATE INDEX IF NOT EXISTS "tenant_export_jobs_tenant_status_idx"
ON "tenant_export_jobs" ("tenant_id", "status");

View File

@@ -358,6 +358,13 @@
"when": 1780261200000,
"tag": "0050_outgoing_document_costcentres",
"breakpoints": true
},
{
"idx": 51,
"version": "7",
"when": 1783247083934,
"tag": "0054_tenant_export_jobs",
"breakpoints": true
}
]
}

View File

@@ -82,6 +82,7 @@ export * from "./taxtypes"
export * from "./telephony_calls"
export * from "./telephony_extensions"
export * from "./telephony_trunks"
export * from "./tenant_export_jobs"
export * from "./tenants"
export * from "./texttemplates"
export * from "./units"

View File

@@ -0,0 +1,41 @@
import {
pgTable,
uuid,
bigint,
timestamp,
text,
integer,
} from "drizzle-orm/pg-core"
import { tenants } from "./tenants"
import { authUsers } from "./auth_users"
export const tenantExportJobs = pgTable("tenant_export_jobs", {
id: uuid("id").primaryKey().defaultRandom(),
createdAt: timestamp("created_at", { withTimezone: true })
.notNull()
.defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }),
completedAt: timestamp("completed_at", { withTimezone: true }),
tenantId: bigint("tenant_id", { mode: "number" })
.notNull()
.references(() => tenants.id, { onDelete: "cascade" }),
createdBy: uuid("created_by").references(() => authUsers.id),
status: text("status").notNull().default("queued"),
filename: text("filename").notNull(),
storagePath: text("storage_path"),
contentType: text("content_type").notNull().default("application/zip"),
fileSize: bigint("file_size", { mode: "number" }),
error: text("error"),
filesTotal: integer("files_total").notNull().default(0),
filesDone: integer("files_done").notNull().default(0),
})
export type TenantExportJob = typeof tenantExportJobs.$inferSelect
export type NewTenantExportJob = typeof tenantExportJobs.$inferInsert