forked from syntaxbullet/aurorabot
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.
This commit is contained in:
17
shared/db/migrations/0004_bored_kat_farrell.sql
Normal file
17
shared/db/migrations/0004_bored_kat_farrell.sql
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
CREATE TABLE "guild_settings" (
|
||||||
|
"guild_id" bigint PRIMARY KEY NOT NULL,
|
||||||
|
"student_role_id" bigint,
|
||||||
|
"visitor_role_id" bigint,
|
||||||
|
"color_role_ids" jsonb DEFAULT '[]'::jsonb,
|
||||||
|
"welcome_channel_id" bigint,
|
||||||
|
"welcome_message" text,
|
||||||
|
"feedback_channel_id" bigint,
|
||||||
|
"terminal_channel_id" bigint,
|
||||||
|
"terminal_message_id" bigint,
|
||||||
|
"moderation_log_channel_id" bigint,
|
||||||
|
"moderation_dm_on_warn" jsonb DEFAULT 'true'::jsonb,
|
||||||
|
"moderation_auto_timeout_threshold" jsonb,
|
||||||
|
"feature_overrides" jsonb DEFAULT '{}'::jsonb,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||||
|
);
|
||||||
1313
shared/db/migrations/meta/0004_snapshot.json
Normal file
1313
shared/db/migrations/meta/0004_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,13 @@
|
|||||||
"when": 1770903573324,
|
"when": 1770903573324,
|
||||||
"tag": "0003_new_senator_kelly",
|
"tag": "0003_new_senator_kelly",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 4,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1770904612078,
|
||||||
|
"tag": "0004_bored_kat_farrell",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
31
shared/db/schema/guild-settings.ts
Normal file
31
shared/db/schema/guild-settings.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
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, () => ({}));
|
||||||
@@ -5,3 +5,4 @@ export * from './economy';
|
|||||||
export * from './quests';
|
export * from './quests';
|
||||||
export * from './moderation';
|
export * from './moderation';
|
||||||
export * from './feature-flags';
|
export * from './feature-flags';
|
||||||
|
export * from './guild-settings';
|
||||||
|
|||||||
Reference in New Issue
Block a user