veza/veza-backend-api/migrations/936_oauth_states_pkce.sql

19 lines
736 B
MySQL
Raw Normal View History

-- 936_oauth_states_pkce.sql
-- OAuth states table with PKCE code_verifier support (v0.902 Sentinel)
CREATE TABLE IF NOT EXISTS public.oauth_states (
id BIGSERIAL PRIMARY KEY,
state_token VARCHAR(255) NOT NULL UNIQUE,
provider VARCHAR(50) NOT NULL,
redirect_url TEXT,
code_verifier VARCHAR(255),
expires_at TIMESTAMPTZ NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_oauth_states_state_token ON public.oauth_states(state_token);
CREATE INDEX IF NOT EXISTS idx_oauth_states_expires_at ON public.oauth_states(expires_at);
-- If table already exists (without code_verifier), add the column
ALTER TABLE public.oauth_states ADD COLUMN IF NOT EXISTS code_verifier VARCHAR(255);