25 lines
1.3 KiB
SQL
25 lines
1.3 KiB
SQL
-- Devotional profile details, plus two system-managed fields reserved for
|
|
-- the (not-yet-built) automated-notification scheduler.
|
|
--
|
|
-- gender / initiated / initiated_at / daily_chanting_rounds are
|
|
-- user-editable from the profile form. preferred_chanting_time and
|
|
-- peak_active_time are written silently by the backend later (no UI yet) —
|
|
-- both store a local clock time as "HH:MM" text so the scheduler can pick
|
|
-- a send window without timezone math at write time.
|
|
ALTER TABLE users
|
|
ADD COLUMN IF NOT EXISTS gender VARCHAR(16),
|
|
ADD COLUMN IF NOT EXISTS initiated BOOLEAN NOT NULL DEFAULT FALSE,
|
|
ADD COLUMN IF NOT EXISTS initiated_at DATE,
|
|
ADD COLUMN IF NOT EXISTS daily_chanting_rounds INTEGER,
|
|
ADD COLUMN IF NOT EXISTS preferred_chanting_time VARCHAR(5),
|
|
ADD COLUMN IF NOT EXISTS peak_active_time VARCHAR(5);
|
|
|
|
-- Guard the chanting-round count to the meaningful range (1 round up to a
|
|
-- full lakh of names = 1008). NULL stays allowed (not specified).
|
|
ALTER TABLE users
|
|
DROP CONSTRAINT IF EXISTS users_daily_chanting_rounds_range;
|
|
ALTER TABLE users
|
|
ADD CONSTRAINT users_daily_chanting_rounds_range
|
|
CHECK (daily_chanting_rounds IS NULL
|
|
OR (daily_chanting_rounds BETWEEN 1 AND 1008));
|