-- Beezifi OAuth integration — run once against the production database

ALTER TABLE users
  ADD COLUMN beezifi_sub VARCHAR(255) DEFAULT NULL UNIQUE;

CREATE TABLE IF NOT EXISTS beezifi_oauth_states (
  state      VARCHAR(64)  NOT NULL PRIMARY KEY,
  nonce      VARCHAR(64)  NOT NULL,
  flow       VARCHAR(10)  NOT NULL DEFAULT 'login',
  user_id    VARCHAR(36)  DEFAULT NULL,
  expires_at TIMESTAMP    NOT NULL,
  INDEX idx_expires (expires_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
