p4bl0t/migrations/20231122220824_guild_log_channels.sql
Lucien Cartier-Tilet fb0ad5be13
feat: add listing logger channels in a guild
This commit also allows in the database to hold more than one channel
per guild and introduces clippy linting.

Closes #2

BREAKING CHANGES: The database schema changed from its root. All
databases should be dropped and recreated before running this new
version.
2023-11-23 22:15:47 +01:00

15 lines
663 B
SQL

-- Add migration script here
-- Discord IDs are kept as INTEGERs and not unsigned INTEGERs despite
-- their Rust type being u64. In order to properly manage them, you'll
-- need to cast any u64 to i64 with `as i64` before writing them to
-- the database, and cast any i64 to u64 with `as u64` when reading
-- them from the database. This operation is noop in Rust and should
-- therefore not cost a single CPU cycle.
CREATE TABLE IF NOT EXISTS guild_log_channels (
guild_id INTEGER NOT NULL,
channel_id INTEGER NOT NULL,
UNIQUE(guild_id, channel_id)
);
CREATE INDEX IF NOT EXISTS guild_log_channels_guild_id ON guild_log_channels(guild_id);