export const userRole = pgEnum("userRole", ["admin", "user"]);
export const users = pgTable("users", {
id: uuid("id").defaultRandom().primaryKey(),
email: text("email").unique().notNull(),
avatar_url: text("avatar_url"),
first_name: text("first_name").notNull(),
last_name: text("last_name").notNull(),
job_title: text("job_title"),
department: text("department"),
slug: text("slug").notNull(),
about_title: text("about_title"),
about: varchar("about", { length: 100 }),
created_at: timestamp("created_at").defaultNow(),
workspace_id: uuid("workspace_id").references(() => workspaces.id, {
onDelete: "cascade",
onUpdate: "cascade"
})
});
export const usersRelations = relations(users, ({ one, many }) => ({
permission: one(permissions, {
fields: [users.email],
references: [permissions.user_email]
}),
contacts: many(contacts,{
relationName: 'users_contacts',
})
}));
export const contactType = pgEnum(....);
export const contacts = pgTable("contacts", {
id: uuid("id").defaultRandom().primaryKey(),
type: contactType("type").default("phone").notNull(),
value: text("value").notNull(),
title: text("title").notNull(),
created_at: timestamp("created_at").defaultNow(),
user_email: text("user_email")
.references(() => users.email, {
onDelete: "cascade",
onUpdate: "cascade"
})
.unique()
.notNull()
});
export const contactsRelations = relations(contacts, ({ many }) => ({
users: many(users)
}));