mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on the s3 save dump feature.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { pgTable, text, boolean, timestamp, uuid, integer, pgEnum, uniqueIndex } from "drizzle-orm/pg-core";
|
||||
import { Agent, agent } from "./07_agent";
|
||||
import { Project, project } from "./05_project";
|
||||
import { relations } from "drizzle-orm";
|
||||
import { dbmsEnum, statusEnum } from "./types";
|
||||
import { createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
import {pgTable, text, boolean, timestamp, uuid, integer, pgEnum, uniqueIndex} from "drizzle-orm/pg-core";
|
||||
import {Agent, agent} from "./07_agent";
|
||||
import {Project, project} from "./05_project";
|
||||
import {relations} from "drizzle-orm";
|
||||
import {dbmsEnum, statusEnum} from "./types";
|
||||
import {createSelectSchema} from "drizzle-zod";
|
||||
import {z} from "zod";
|
||||
|
||||
export const database = pgTable("databases", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
@@ -19,7 +19,7 @@ export const database = pgTable("databases", {
|
||||
updatedAt: timestamp("updated_at"),
|
||||
agentId: uuid("agent_id")
|
||||
.notNull()
|
||||
.references(() => agent.id, { onDelete: "cascade" }),
|
||||
.references(() => agent.id, {onDelete: "cascade"}),
|
||||
lastContact: timestamp("last_contact"),
|
||||
|
||||
projectId: uuid("project_id")
|
||||
@@ -36,7 +36,7 @@ export const backup = pgTable(
|
||||
updatedAt: timestamp("updated_at"),
|
||||
databaseId: uuid("database_id")
|
||||
.notNull()
|
||||
.references(() => database.id, { onDelete: "cascade" }),
|
||||
.references(() => database.id, {onDelete: "cascade"}),
|
||||
},
|
||||
// (table) => [uniqueIndex("database_id_status_unique").on(table.databaseId, table.status)]
|
||||
);
|
||||
@@ -48,25 +48,25 @@ export const restoration = pgTable("restorations", {
|
||||
updatedAt: timestamp("updated_at"),
|
||||
backupId: uuid("backup_id")
|
||||
.notNull()
|
||||
.references(() => backup.id, { onDelete: "cascade" }),
|
||||
databaseId: uuid("database_id").references(() => database.id, { onDelete: "cascade" }),
|
||||
.references(() => backup.id, {onDelete: "cascade"}),
|
||||
databaseId: uuid("database_id").references(() => database.id, {onDelete: "cascade"}),
|
||||
});
|
||||
|
||||
export const databaseRelations = relations(database, ({ one, many }) => ({
|
||||
agent: one(agent, { fields: [database.agentId], references: [agent.id] }),
|
||||
project: one(project, { fields: [database.projectId], references: [project.id] }),
|
||||
export const databaseRelations = relations(database, ({one, many}) => ({
|
||||
agent: one(agent, {fields: [database.agentId], references: [agent.id]}),
|
||||
project: one(project, {fields: [database.projectId], references: [project.id]}),
|
||||
backups: many(backup),
|
||||
restorations: many(restoration),
|
||||
}));
|
||||
|
||||
export const backupRelations = relations(backup, ({ one, many }) => ({
|
||||
database: one(database, { fields: [backup.databaseId], references: [database.id] }),
|
||||
export const backupRelations = relations(backup, ({one, many}) => ({
|
||||
database: one(database, {fields: [backup.databaseId], references: [database.id]}),
|
||||
restorations: many(restoration),
|
||||
}));
|
||||
|
||||
export const restorationRelations = relations(restoration, ({ one }) => ({
|
||||
backup: one(backup, { fields: [restoration.backupId], references: [backup.id] }),
|
||||
database: one(database, { fields: [restoration.databaseId], references: [database.id] }),
|
||||
export const restorationRelations = relations(restoration, ({one}) => ({
|
||||
backup: one(backup, {fields: [restoration.backupId], references: [backup.id]}),
|
||||
database: one(database, {fields: [restoration.databaseId], references: [database.id]}),
|
||||
}));
|
||||
|
||||
export const databaseSchema = createSelectSchema(database);
|
||||
@@ -79,8 +79,9 @@ export const restorationSchema = createSelectSchema(restoration);
|
||||
export type Restoration = z.infer<typeof restorationSchema>;
|
||||
|
||||
export type DatabaseWith = Database & {
|
||||
agent: Agent;
|
||||
project: Project;
|
||||
backups: Backup[];
|
||||
restorations: Restoration[];
|
||||
agent?: Agent | null;
|
||||
project?: Project | null;
|
||||
backups?: Backup[] | null;
|
||||
restorations?: Restoration[] | null;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user