g1t/services/deployments/migrations/0005_domains.sql
| 1 | -- Custom domains: a project's production at a hostname of its own. Each is |
| 2 | -- a Cloudflare for SaaS custom hostname on the g1t.page zone; the |
| 3 | -- dispatcher finds its app in the g1t-domains KV namespace. See |
| 4 | -- src/domains.ts. |
| 5 | CREATE TABLE domains ( |
| 6 | id TEXT PRIMARY KEY, |
| 7 | project_id TEXT NOT NULL, |
| 8 | workspace TEXT NOT NULL, |
| 9 | slug TEXT NOT NULL, |
| 10 | -- Lowercase, punycode. |
| 11 | hostname TEXT NOT NULL UNIQUE, |
| 12 | -- What it serves: production (a branch, later). |
| 13 | target TEXT NOT NULL DEFAULT 'production', |
| 14 | -- Cloudflare's id for it; null until Cloudflare has it. |
| 15 | cf_hostname_id TEXT, |
| 16 | -- pending, verifying, active, failed or removing. |
| 17 | status TEXT NOT NULL, |
| 18 | -- Cloudflare's state for its certificate, as given. |
| 19 | ssl_status TEXT, |
| 20 | -- A JSON array of the records Cloudflare asks for: ownership, and any |
| 21 | -- the certificate's validation needs. |
| 22 | records TEXT NOT NULL DEFAULT '[]', |
| 23 | -- For a www/apex pair: the hostname this one redirects to. |
| 24 | redirect_to TEXT, |
| 25 | -- The script its KV entry names, to rewrite it only when that changes. |
| 26 | script TEXT, |
| 27 | -- Why it is not active, or failed. |
| 28 | error TEXT, |
| 29 | created_by TEXT NOT NULL, |
| 30 | created_at TEXT NOT NULL, |
| 31 | verified_at TEXT, |
| 32 | checked_at TEXT |
| 33 | ); |
| 34 | CREATE INDEX domains_by_project ON domains (project_id); |
| 35 | CREATE INDEX domains_by_workspace ON domains (workspace); |
| 36 | CREATE INDEX domains_by_status ON domains (status, checked_at); |
| 37 | |
| 38 | -- The most custom domains the workspace had at once this month, charged |
| 39 | -- past the plan's once the month is over. |
| 40 | ALTER TABLE meters ADD COLUMN peak_domains INTEGER NOT NULL DEFAULT 0; |