-- Gitea team recruitment (M20) -- -- Applications are stored before the team reviews them: the panel is pressed by -- members, not staff, so losing an application on restart would mean asking -- someone to fill the whole form again. The panel message is remembered too, so -- re-running the installation edits it instead of stacking a second copy. CREATE TABLE IF NOT EXISTS gitea_applications ( id INTEGER PRIMARY KEY AUTOINCREMENT, guild_id TEXT NOT NULL, user_id TEXT NOT NULL, languages TEXT NOT NULL, level TEXT NOT NULL, experience TEXT, gitea_username TEXT NOT NULL, email TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN ('pending', 'accepted', 'rejected')), channel_id TEXT, message_id TEXT, reviewed_by TEXT, reviewed_at TEXT, gitea_user_id INTEGER, created_at TEXT NOT NULL DEFAULT (datetime('now')) ); -- One open application per member: a second one would give the team two -- buttons for the same person and could create their Gitea account twice. CREATE UNIQUE INDEX IF NOT EXISTS idx_gitea_applications_pending_member ON gitea_applications (guild_id, user_id) WHERE status = 'pending'; CREATE INDEX IF NOT EXISTS idx_gitea_applications_status ON gitea_applications (guild_id, status); CREATE TABLE IF NOT EXISTS gitea_recruitment_panels ( guild_id TEXT PRIMARY KEY, category_id TEXT, channel_id TEXT NOT NULL, message_id TEXT, updated_at TEXT NOT NULL DEFAULT (datetime('now')) );