Files
discord-rpg-concept/shared/db/schema/guild-settings.ts
syntaxbullet 5f107d03a7 feat(db): add guild_settings table for per-guild configuration
Store guild-specific settings (roles, channels, moderation options) in
database instead of config file, enabling per-guild configuration and
runtime updates without redeployment.
2026-02-12 14:57:24 +01:00

32 lines
1.6 KiB
TypeScript

import {
pgTable,
bigint,
timestamp,
text,
jsonb,
} from 'drizzle-orm/pg-core';
import { relations, type InferSelectModel, type InferInsertModel } from 'drizzle-orm';
export type GuildSettings = InferSelectModel<typeof guildSettings>;
export type GuildSettingsInsert = InferInsertModel<typeof guildSettings>;
export const guildSettings = pgTable('guild_settings', {
guildId: bigint('guild_id', { mode: 'bigint' }).primaryKey(),
studentRoleId: bigint('student_role_id', { mode: 'bigint' }),
visitorRoleId: bigint('visitor_role_id', { mode: 'bigint' }),
colorRoleIds: jsonb('color_role_ids').$type<string[]>().default([]),
welcomeChannelId: bigint('welcome_channel_id', { mode: 'bigint' }),
welcomeMessage: text('welcome_message'),
feedbackChannelId: bigint('feedback_channel_id', { mode: 'bigint' }),
terminalChannelId: bigint('terminal_channel_id', { mode: 'bigint' }),
terminalMessageId: bigint('terminal_message_id', { mode: 'bigint' }),
moderationLogChannelId: bigint('moderation_log_channel_id', { mode: 'bigint' }),
moderationDmOnWarn: jsonb('moderation_dm_on_warn').$type<boolean>().default(true),
moderationAutoTimeoutThreshold: jsonb('moderation_auto_timeout_threshold').$type<number>(),
featureOverrides: jsonb('feature_overrides').$type<Record<string, boolean>>().default({}),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
});
export const guildSettingsRelations = relations(guildSettings, () => ({}));