groups api route
This commit is contained in:
60
drizzle/schema.ts
Normal file
60
drizzle/schema.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { pgTable, foreignKey, unique, uuid, text, boolean, date } from "drizzle-orm/pg-core"
|
||||
import { sql } from "drizzle-orm"
|
||||
|
||||
|
||||
|
||||
export const groups = pgTable("groups", {
|
||||
id: uuid("id").defaultRandom().primaryKey().notNull(),
|
||||
userId: uuid("user_id").references(() => users.id),
|
||||
email: text("email").notNull(),
|
||||
name: text("name").notNull(),
|
||||
},
|
||||
(table) => {
|
||||
return {
|
||||
groupsEmailUnique: unique("groups_email_unique").on(table.email),
|
||||
}
|
||||
});
|
||||
|
||||
export const sources = pgTable("sources", {
|
||||
id: uuid("id").defaultRandom().primaryKey().notNull(),
|
||||
groupId: uuid("group_id").notNull().references(() => groups.id),
|
||||
name: text("name").notNull(),
|
||||
isConfirmed: boolean("is_confirmed").default(false).notNull(),
|
||||
});
|
||||
|
||||
export const letters = pgTable("letters", {
|
||||
id: uuid("id").defaultRandom().primaryKey().notNull(),
|
||||
sender: text("sender").notNull(),
|
||||
content: text("content").notNull(),
|
||||
groupId: uuid("group_id").notNull().references(() => groups.id),
|
||||
dateCreated: date("date_created").defaultNow().notNull(),
|
||||
senderEmail: text("sender_email").notNull(),
|
||||
subject: text("subject").notNull(),
|
||||
});
|
||||
|
||||
export const sessions = pgTable("sessions", {
|
||||
id: uuid("id").defaultRandom().primaryKey().notNull(),
|
||||
userId: uuid("user_id").notNull(),
|
||||
dateCreated: date("date_created").defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export const users = pgTable("users", {
|
||||
id: uuid("id").defaultRandom().primaryKey().notNull(),
|
||||
name: text("name").notNull(),
|
||||
email: text("email").notNull(),
|
||||
hashedPassword: text("hashed_password").notNull(),
|
||||
dateCreated: date("date_created").defaultNow().notNull(),
|
||||
},
|
||||
(table) => {
|
||||
return {
|
||||
usersEmailUnique: unique("users_email_unique").on(table.email),
|
||||
}
|
||||
});
|
||||
|
||||
export const pods = pgTable("pods", {
|
||||
id: uuid("id").defaultRandom().primaryKey().notNull(),
|
||||
userId: uuid("user_id").references(() => users.id),
|
||||
script: text("script").notNull(),
|
||||
dateCreated: date("date_created").defaultNow().notNull(),
|
||||
groupId: uuid("group_id").references(() => groups.id),
|
||||
});
|
||||
Reference in New Issue
Block a user