feat: Working on UI/UX for multiple storage backends.

This commit is contained in:
charlesgauthereau
2026-01-17 15:57:37 +01:00
parent ecf80280f1
commit 0216c40bfe
22 changed files with 556 additions and 39 deletions
+8 -1
View File
@@ -8,7 +8,7 @@ import {z} from "zod";
import {timestamps} from "@/db/schema/00_common";
import {AlertPolicy, alertPolicy} from "@/db/schema/10_alert-policy";
import {StoragePolicy, storagePolicy} from "@/db/schema/13_storage-policy";
import {backupStorage} from "@/db/schema/14_storage-backup";
import {BackupStorage, backupStorage} from "@/db/schema/14_storage-backup";
export const database = pgTable("databases", {
id: uuid("id").primaryKey().defaultRandom(),
@@ -126,3 +126,10 @@ export type DatabaseWith = Database & {
storagePolicies?: StoragePolicy[] | null;
};
export type BackupWith = Backup & {
restorations?: Restoration[] | null;
storages?: BackupStorage[] | null;
};
+15 -3
View File
@@ -1,8 +1,10 @@
import { pgTable, uuid, text, integer, pgEnum } from "drizzle-orm/pg-core";
import { timestamps } from "@/db/schema/00_common";
import { storageChannel } from "@/db/schema/12_storage-channel";
import {backup} from "@/db/schema/07_database";
import {StorageChannel, storageChannel} from "@/db/schema/12_storage-channel";
import {Backup, backup, Restoration} from "@/db/schema/07_database";
import {relations} from "drizzle-orm";
import {createSelectSchema} from "drizzle-zod";
import {z} from "zod";
export const backupStorageStatusEnum = pgEnum("backup_storage_status", [
"pending",
@@ -35,4 +37,14 @@ export const backupStorageRelations = relations(backupStorage, ({ one }) => ({
fields: [backupStorage.storageChannelId],
references: [storageChannel.id],
}),
}));
}));
export const backupStorageSchema = createSelectSchema(backupStorage);
export type BackupStorage = z.infer<typeof backupStorageSchema>;
export type BackupStorageWith = BackupStorage & {
storageChannel?: StorageChannel | null;
};
+19
View File
@@ -0,0 +1,19 @@
"use server"
import {eq} from "drizzle-orm";
import * as drizzleDb from "@/db";
import {db} from "@/db";
export async function getDatabaseBackups(databaseId: string) {
return await db.query.backup.findMany({
where: eq(drizzleDb.schemas.backup.databaseId, databaseId),
with: {
restorations: true,
storages: {
with: {
storageChannel: true,
},
},
},
orderBy: (b, {desc}) => [desc(b.createdAt)],
});
}