export const users = pgTable('users', {
id: varchar('id', {length: 256}).primaryKey(),
authId: varchar('auth_id', {length: 256}).unique(),
firstName: varchar('first_name', { length: 256 }),
lastName: varchar('last_name', { length: 256 }),
email: varchar('email', { length: 256 }).notNull(),
teamId: varchar('team_id', {length:256}).references(() => teams.id),
role: roleEnum('role').notNull(),
isStaff: boolean('is_staff').default(false),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export const usersRelations = relations(users, ({ one }) => ({
team: one(teams, {
fields: [users.id],
references: [teams.id],
}),
}));
export type User = typeof users.$inferSelect;
export type NewUser = typeof users.$inferInsert;
export const teams = pgTable('teams', {
id: varchar('id', {length: 256}).primaryKey(),
name: varchar('name', { length: 256 }),
createdAt: timestamp('created_at').defaultNow(),
updatedAt: timestamp('updated_at').defaultNow(),
});
export const teamsRelations = relations(teams, ({ many }) => ({
users: many(users),
}));