Files
mixmaker/backend/migrations/011_discord_role_sync.sql
lemintare c3624376b0
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / compose (push) Has been cancelled
Add Discord guild ID configuration and enhance event announcement options
This commit introduces the `DISCORD_GUILD_ID` environment variable to the configuration files, allowing for better integration with Discord for role synchronization. The event announcement functionality has been updated to include an option for the `@everyone` mention, which can be toggled during event creation. The backend logic has been modified to handle this new option, and corresponding updates have been made to the frontend to allow users to control the mention behavior. Additionally, tests have been added to ensure the correct functionality of these features.
2026-07-19 11:34:11 +03:00

43 lines
1.6 KiB
SQL

-- +mixmaker Up
CREATE TABLE discord_managed_roles (
scope text NOT NULL CHECK (scope IN ('global', 'event')),
event_id text NOT NULL DEFAULT '',
team_id text NOT NULL DEFAULT '',
kind text NOT NULL CHECK (kind IN ('tank', 'damage', 'support', 'team', 'captain')),
discord_role_id text NOT NULL UNIQUE,
role_name text NOT NULL,
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (scope, event_id, team_id, kind)
);
CREATE TABLE discord_role_assignments (
discord_role_id text NOT NULL REFERENCES discord_managed_roles(discord_role_id) ON DELETE CASCADE,
discord_user_id text NOT NULL,
updated_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (discord_role_id, discord_user_id)
);
CREATE TABLE discord_role_sync_jobs (
id bigserial PRIMARY KEY,
event_id text NOT NULL,
action text NOT NULL CHECK (action IN ('reconcile', 'teardown')),
generation bigint NOT NULL,
role_snapshot jsonb NOT NULL DEFAULT '[]'::jsonb,
status text NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'processing', 'completed')),
attempts integer NOT NULL DEFAULT 0,
available_at timestamptz NOT NULL DEFAULT now(),
last_error text NOT NULL DEFAULT '',
created_at timestamptz NOT NULL DEFAULT now(),
updated_at timestamptz NOT NULL DEFAULT now(),
completed_at timestamptz,
UNIQUE (event_id, action, generation)
);
CREATE INDEX discord_role_sync_jobs_claim_idx
ON discord_role_sync_jobs(status, available_at, id);
-- +mixmaker Down
DROP TABLE IF EXISTS discord_role_sync_jobs;
DROP TABLE IF EXISTS discord_role_assignments;
DROP TABLE IF EXISTS discord_managed_roles;