112 lines · 3.9 KB
-- sites: squashed from 1300_sites.sql, 1301_sites_domain_checks.sql, 1302_scratch_git_usage.sql.

-- Dynamic sites: isolated per-repo origins on SITES_DOMAIN, access control, branch previews and scratch deploys.
CREATE TABLE sites (
  id TEXT PRIMARY KEY,
  owner_id TEXT REFERENCES accounts(id) ON DELETE CASCADE,
  repo_id TEXT UNIQUE REFERENCES repos(id) ON DELETE CASCADE,
  label TEXT NOT NULL UNIQUE,
  source TEXT NOT NULL CHECK (source IN ('branch', 'workflow', 'upload')),
  branch TEXT NOT NULL DEFAULT 'main',
  folder TEXT NOT NULL DEFAULT '',
  artifact_name TEXT NOT NULL DEFAULT 'site',
  spa INTEGER NOT NULL DEFAULT 0,
  previews INTEGER NOT NULL DEFAULT 1,
  access TEXT NOT NULL DEFAULT 'public' CHECK (access IN ('public', 'password', 'gitfor', 'oidc')),
  audience TEXT NOT NULL DEFAULT 'readers' CHECK (audience IN ('readers', 'members')),
  password_hash TEXT,
  oidc_issuer TEXT,
  oidc_client_id TEXT,
  oidc_secret_ct TEXT,
  oidc_secret_iv TEXT,
  oidc_allowed TEXT,
  access_version INTEGER NOT NULL DEFAULT 1,
  env_version INTEGER NOT NULL DEFAULT 1,
  custom_domain TEXT UNIQUE,
  custom_hostname_id TEXT,
  domain_status TEXT,
  domain_claimed_at INTEGER,
  domain_token TEXT,
  active_deployment_id TEXT,
  scratch INTEGER NOT NULL DEFAULT 0,
  claim_token_hash TEXT,
  creator_ip_hash TEXT,
  expires_at INTEGER,
  disabled_reason TEXT,
  created_at INTEGER NOT NULL,
  updated_at INTEGER NOT NULL,
  domain_checked_at INTEGER,
  push_token_hash TEXT
);