neon-sprawl/server/db/migrations/V008__player_quest_progress...

14 lines
682 B
SQL

-- NEO-116: per-player quest progress rows (prototype E7.M1 Slice 1).
CREATE TABLE IF NOT EXISTS player_quest_progress (
player_id TEXT NOT NULL REFERENCES player_position(player_id) ON DELETE CASCADE,
quest_id TEXT NOT NULL,
status TEXT NOT NULL CHECK (status IN ('active', 'completed')),
current_step_index INTEGER NOT NULL CHECK (current_step_index >= 0),
objective_counters JSONB NOT NULL DEFAULT '{}'::jsonb,
completed_at TIMESTAMPTZ,
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (player_id, quest_id)
);
COMMENT ON TABLE player_quest_progress IS 'Persisted quest step state per player (NEO-116); missing row means not_started.';