import { pgTable, uuid, text, boolean, timestamp, index } from 'drizzle-orm/pg-core'; import { sql } from 'drizzle-orm'; export const roles = pgTable('roles', { id: uuid('id').primaryKey().default(sql`gen_random_uuid()`), name: text('name').notNull().unique(), description: text('description'), tasks: text('tasks').array().notNull().default(sql`'{}'`), isSystem: boolean('is_system').notNull().default(false), isActive: boolean('is_active').notNull().default(true), createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(), updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow().$onUpdate(() => new Date()), }, (t) => [ index('roles_is_active_idx').on(t.isActive), ]); export type Role = typeof roles.$inferSelect; export type NewRole = typeof roles.$inferInsert;