mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
feat: Working on UI/UX for multiple storage backends.
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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)],
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user