mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
* feat: working on migration backup tool * feat: add migration sequences * fix: responsive for migration tool * fix: truncate database name in migration * fix: filter on databases success for migration tool --------- Co-authored-by: charles-gauthereau <charles.gauthereau@soluce-technologies.com>
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
import {pgTable, text, boolean, uuid} from "drizzle-orm/pg-core";
|
|
import {relations} from "drizzle-orm";
|
|
import {Organization, organization} from "./03_organization";
|
|
import {createSelectSchema} from "drizzle-zod";
|
|
import {z} from "zod";
|
|
import {Database, database, DatabaseWith} from "./07_database";
|
|
import {timestamps} from "@/db/schema/00_common";
|
|
|
|
export const project = pgTable("projects", {
|
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
slug: text("slug").notNull().unique(),
|
|
name: text("name").notNull().notNull(),
|
|
isArchived: boolean("is_archived").default(false),
|
|
organizationId: uuid("organization_id")
|
|
.notNull()
|
|
.references(() => organization.id, {onDelete: "cascade"}),
|
|
...timestamps
|
|
});
|
|
|
|
export const projectRelations = relations(project, ({one, many}) => ({
|
|
organization: one(organization, {
|
|
fields: [project.organizationId],
|
|
references: [organization.id],
|
|
}),
|
|
databases: many(database),
|
|
}));
|
|
|
|
export const projectSchema = createSelectSchema(project);
|
|
export type Project = z.infer<typeof projectSchema>;
|
|
|
|
export type ProjectWith = Project & {
|
|
databases: Database[];
|
|
organization: Organization;
|
|
};
|
|
|
|
export type ProjectWithDatabasesAndBackups = Project & {
|
|
databases: DatabaseWith[];
|
|
organization: Organization;
|
|
};
|
|
|