Files
portabase/src/db/schema/02_organization.ts
T

31 lines
981 B
TypeScript
Raw Normal View History

2025-05-16 15:54:17 +02:00
import { pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm";
2025-07-16 12:36:11 +02:00
import { project } from "./05_project";
2025-05-16 15:54:17 +02:00
import { createSelectSchema } from "drizzle-zod";
import { z } from "zod";
2025-07-16 12:36:11 +02:00
import {invitation} from "@/db/schema/04_invitation";
import {member} from "@/db/schema/03_member";
2025-05-16 15:54:17 +02:00
export const organization = pgTable("organization", {
id: uuid("id").defaultRandom().primaryKey(),
name: text("name").notNull(),
slug: text("slug").unique().notNull(),
logo: text("logo"),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at"),
metadata: text("metadata"),
});
export const organizationRelations = relations(organization, ({ many }) => ({
members: many(member),
invitations: many(invitation),
projects: many(project),
}));
export const organizationSchema = createSelectSchema(organization);
export type Organization = z.infer<typeof organizationSchema>;