MySQL · 909 bytes Raw Blame History
1 -- SPDX-License-Identifier: AGPL-3.0-or-later
2 --
3 -- Account-settings columns:
4 --
5 -- - theme: persisted theme preference (cookie is the fast path, DB is
6 -- the source of truth across devices). NULL → fall back to cookie/auto.
7 -- - session_epoch: bumped by "log out everywhere" so existing cookies
8 -- carrying a stale epoch fail validation on the next request.
9 --
10 -- The username-change rate-limit window is implicit in
11 -- username_redirects.changed_at — we count rows in the last 60 days
12 -- per user to enforce the 3/60d cap. No new column needed.
13
14 -- +goose Up
15 ALTER TABLE users
16 ADD COLUMN theme text NOT NULL DEFAULT '',
17 ADD COLUMN session_epoch integer NOT NULL DEFAULT 0,
18 ADD CONSTRAINT users_theme_known CHECK (theme IN ('', 'light', 'dark', 'auto', 'high_contrast'));
19
20 -- +goose Down
21 ALTER TABLE users
22 DROP COLUMN IF EXISTS theme,
23 DROP COLUMN IF EXISTS session_epoch;
24