Files
panel/controller/internal/db/migrations/009_steam_login.sql
T
2026-07-14 23:25:11 -07:00

23 lines
1.0 KiB
SQL

-- 009_steam_login.sql — Steam OpenID sign-in support.
--
-- Adds a nullable `steam_id` column to `users` so an admin or operator
-- can log in with their Steam account instead of (or in addition to)
-- email + password.
--
-- steam_id stores the 17-digit SteamID64 as TEXT (not BIGINT) because
-- while the value fits in uint64, using TEXT avoids any sign-extension
-- surprises across the app / frontend / logs. Unique constraint so one
-- Steam account can only be linked to one panel user.
--
-- password_hash is made nullable: a user may exist who only signs in via
-- Steam with no local password. The email column stays NOT NULL — even
-- Steam-only users need a panel identity, we auto-fill with the
-- Steam-derived email "steam+<steamid>@panel.local" when there's nothing
-- better.
ALTER TABLE users ADD COLUMN steam_id TEXT;
ALTER TABLE users ADD CONSTRAINT users_steam_id_unique UNIQUE (steam_id);
ALTER TABLE users ALTER COLUMN password_hash DROP NOT NULL;
CREATE INDEX idx_users_steam_id ON users(steam_id) WHERE steam_id IS NOT NULL;