CREATE TABLE oauth_providers (
  id              uuid        PRIMARY KEY DEFAULT gen_random_uuid(),
  provider_type   text        NOT NULL CHECK (provider_type IN ('github', 'gitea', 'oidc')),
  display_name    text        NOT NULL,
  slug            text        UNIQUE NOT NULL,
  client_id       text        NOT NULL,
  client_secret   text        NOT NULL,
  base_url        text,
  issuer_url      text,
  enabled         boolean     NOT NULL DEFAULT true,
  sort_order      integer     NOT NULL DEFAULT 0,
  created_at      timestamptz DEFAULT now(),
  updated_at      timestamptz DEFAULT now()
);
--;;
CREATE INDEX idx_oauth_providers_enabled ON oauth_providers (enabled, sort_order);
