feat: config management
fuck it we're vibecoding now
This commit is contained in:
parent
1ea3f3ba97
commit
1eb2200fbe
14 changed files with 1082 additions and 33 deletions
|
|
@ -1,5 +1,20 @@
|
|||
import { sql } from 'drizzle-orm'
|
||||
import { bigint, pgTable, timestamp, uuid, varchar } from 'drizzle-orm/pg-core'
|
||||
import { bigint, pgEnum, pgTable, timestamp, uuid, varchar } from 'drizzle-orm/pg-core'
|
||||
|
||||
// Enums for permission levels
|
||||
export const roleManagePermissionEnum = pgEnum('role_manage_permission', [
|
||||
'everyone',
|
||||
'all_admins',
|
||||
'admin_can_promote_members',
|
||||
'admin_can_change_info',
|
||||
'admin_can_manage_chat',
|
||||
'only_owner',
|
||||
])
|
||||
|
||||
export const roleMentionPermissionEnum = pgEnum('role_mention_permission', [
|
||||
'everyone',
|
||||
'all_admins',
|
||||
'only_owner',
|
||||
])
|
||||
|
||||
export const roleSchema = pgTable('roles', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
|
@ -8,7 +23,7 @@ export const roleSchema = pgTable('roles', {
|
|||
chatId: bigint('chat_id', { mode: 'number' }).notNull(),
|
||||
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at').notNull().defaultNow().$onUpdate(() => sql`now()`),
|
||||
updatedAt: timestamp('updated_at').notNull().defaultNow().$onUpdate(() => new Date()),
|
||||
})
|
||||
|
||||
export const roleMembersSchema = pgTable('role_members', {
|
||||
|
|
@ -18,3 +33,21 @@ export const roleMembersSchema = pgTable('role_members', {
|
|||
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
})
|
||||
|
||||
export const chatConfigSchema = pgTable('chat_configs', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
chatId: bigint('chat_id', { mode: 'number' }).notNull().unique(),
|
||||
|
||||
// Who can manage roles (add/delete)
|
||||
roleManagePermission: roleManagePermissionEnum('role_manage_permission')
|
||||
.notNull()
|
||||
.default('all_admins'),
|
||||
|
||||
// Who can mention roles (@role or /role commands)
|
||||
roleMentionPermission: roleMentionPermissionEnum('role_mention_permission')
|
||||
.notNull()
|
||||
.default('everyone'),
|
||||
|
||||
createdAt: timestamp('created_at').notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at').notNull().defaultNow().$onUpdate(() => new Date()),
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue