upd
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { pgTable, serial, text, timestamp, uuid } from "drizzle-orm/pg-core";
|
||||
import { usersTable } from "./users";
|
||||
import { sessionsTable } from "./sessions";
|
||||
import { relations } from "drizzle-orm";
|
||||
|
||||
export const commentsTable = pgTable("comments", {
|
||||
id: serial("id").primaryKey(),
|
||||
text: text("text").notNull(),
|
||||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
||||
ownerId: uuid("owner_id")
|
||||
.notNull()
|
||||
.references(() => usersTable.id),
|
||||
sessionId: uuid("session_id")
|
||||
.notNull()
|
||||
.references(() => sessionsTable.id),
|
||||
});
|
||||
|
||||
export const commentsRelations = relations(commentsTable, ({ one }) => ({
|
||||
owner: one(usersTable, {
|
||||
fields: [commentsTable.ownerId],
|
||||
references: [usersTable.id],
|
||||
}),
|
||||
session: one(sessionsTable, {
|
||||
fields: [commentsTable.sessionId],
|
||||
references: [sessionsTable.id],
|
||||
}),
|
||||
}));
|
||||
@@ -6,3 +6,4 @@ export * from "./sessions";
|
||||
export * from "./clients";
|
||||
export * from "./apps";
|
||||
export * from "./actions";
|
||||
export * from "./comments";
|
||||
|
||||
Reference in New Issue
Block a user