This commit introduces a new feature for global role synchronization in Discord, allowing for periodic reconciliation of managed roles. A new environment variable, `DISCORD_GLOBAL_SYNC_INTERVAL`, has been added to configure the synchronization interval, defaulting to 5 minutes. The `RoleWorker` has been updated to schedule global sync jobs, ensuring that missing managed roles are restored and extra assignments are removed without affecting unrelated server roles. Database schema changes support the new synchronization logic, and tests have been added to validate the functionality of the global reconciliation process.
13 lines
605 B
SQL
13 lines
605 B
SQL
-- +mixmaker Up
|
|
ALTER TABLE discord_role_sync_jobs DROP CONSTRAINT IF EXISTS discord_role_sync_jobs_action_check;
|
|
ALTER TABLE discord_role_sync_jobs ADD CONSTRAINT discord_role_sync_jobs_action_check CHECK (
|
|
action IN ('reconcile', 'rsvp', 'full_reconcile', 'teardown')
|
|
);
|
|
|
|
-- +mixmaker Down
|
|
DELETE FROM discord_role_sync_jobs WHERE action='full_reconcile';
|
|
ALTER TABLE discord_role_sync_jobs DROP CONSTRAINT IF EXISTS discord_role_sync_jobs_action_check;
|
|
ALTER TABLE discord_role_sync_jobs ADD CONSTRAINT discord_role_sync_jobs_action_check CHECK (
|
|
action IN ('reconcile', 'rsvp', 'teardown')
|
|
);
|