Files
pragativeer-v2/migrations/002_schema_updates.sql

11 lines
574 B
SQL

-- Schema Updates: terms_agreed, pdf_url, streaks
ALTER TABLE "user" ADD COLUMN IF NOT EXISTS terms_agreed BOOLEAN DEFAULT FALSE;
ALTER TABLE "user" ADD COLUMN IF NOT EXISTS streak_count INTEGER NOT NULL DEFAULT 0;
ALTER TABLE "user" ADD COLUMN IF NOT EXISTS longest_streak INTEGER NOT NULL DEFAULT 0;
ALTER TABLE "user" ADD COLUMN IF NOT EXISTS is_active BOOLEAN DEFAULT TRUE;
ALTER TABLE "test" ADD COLUMN IF NOT EXISTS pdf_url VARCHAR;
-- Update existing streaks to have default 1 if empty
UPDATE "user" SET streak_count = 1, longest_streak = 1 WHERE streak_count = 0;