Console has been deployed since 2026-10-14 but sign-in never worked: SCRIBASE_URL was baked to the Scribase control-plane API (api.scribase.com) instead of a real project's own gateway, because no project had ever been provisioned for it. Also fixed a real, unrelated bug found while provisioning: the control-api's real-time project-runtime image (scribase-project-runtime:local) had been reclaimed by a routine docker image prune (it has no running container, so it's unprotected) -- this broke every new Scribase project, temp or paid, not just this one. Rebuilt it on box 1 via the documented narrow compose step. Provisioned a real (temporary, 72h TTL) Scribase project for the console via `npx scribase init --temp --yes` against production, applied all 14 of db/migrations/*.sql against it via the real database/execute API (0007_ship.sql had a literal backslash in a regex that the SQL-execute endpoint's injection guard rejects outside E'...'/$$...$$ -- rewrote `github\.com` as the behaviorally-identical `github[.]com` character class; existing tests already only check accept/reject behavior, unaffected), and wired the real anon/service role keys via `wrangler secret put`. Deployed (version 49f09f0f-d84b-4379-acc4-d1a78df81a90) and verified end to end: a real POST to /auth/email now reaches the real gateway's /auth/v1/otp (confirmed by direct curl to the gateway, bypassing the app) and correctly hits GoTrue's own over_email_send_rate_limit after repeated test calls -- proof the full app -> SCRIBASE_URL -> gateway -> GoTrue chain is for real wired correctly, not the prior 404 "route not found" / zero-project-exists failure. Remaining real step (not done here): this project is temporary and expires in 72h. A permanent one needs either a real SCRIBASE_ACCESS_TOKEN for the ereboslab org, or the $1 Dodo card-check "Keep this project" flow at the project's claim URL -- both genuinely owner-gated (2FA / a real card), see plans/railyard.md and apps/console/DEPLOY.md for the exact next step.
75 lines
4.2 KiB
SQL
75 lines
4.2 KiB
SQL
-- Ship on push (Wave P PY3.1, RYP-E3, ADR RY-0004): GitHub App installations,
|
|
-- linked repositories, the org's Cloudflare grant (sealed) and the short
|
|
-- `railyard link` browser sessions.
|
|
-- Idempotent: every statement can run again without error or change. Not
|
|
-- applied by agents to any hosted database; the owner applies it after 0006
|
|
-- (owner step), agents only to a scratch Postgres.
|
|
|
|
create table if not exists railyard.github_installations (
|
|
installation_id bigint primary key check (installation_id > 0),
|
|
org_id uuid not null references railyard.orgs (id) on delete cascade,
|
|
account_login text not null check (account_login ~ '^[A-Za-z0-9][A-Za-z0-9-]{0,38}$'),
|
|
created_at timestamptz not null default now()
|
|
);
|
|
create index if not exists github_installations_org_idx on railyard.github_installations (org_id);
|
|
|
|
create table if not exists railyard.ship_links (
|
|
id uuid primary key default gen_random_uuid(),
|
|
org_id uuid not null references railyard.orgs (id) on delete cascade,
|
|
app text not null check (app ~ '^[a-z0-9][a-z0-9-]{0,39}$'),
|
|
repo_id bigint not null unique check (repo_id > 0),
|
|
repo_full_name text not null check (repo_full_name ~ '^[A-Za-z0-9][A-Za-z0-9-]{0,38}/[A-Za-z0-9._-]{1,100}$'),
|
|
installation_id bigint not null check (installation_id > 0),
|
|
production_branch text not null check (length(production_branch) between 1 and 200),
|
|
workflow_pr_url text check (workflow_pr_url is null or workflow_pr_url ~ '^https://github[.]com/'),
|
|
created_at timestamptz not null default now()
|
|
);
|
|
create index if not exists ship_links_org_idx on railyard.ship_links (org_id);
|
|
create index if not exists ship_links_installation_idx on railyard.ship_links (installation_id);
|
|
|
|
-- Sealed only: nonce + ciphertext (AES-256-GCM, org id as associated data).
|
|
create table if not exists railyard.cloudflare_connections (
|
|
org_id uuid primary key references railyard.orgs (id) on delete cascade,
|
|
account_id text not null check (account_id ~ '^[0-9a-f]{32}$'),
|
|
account_name text not null default '' check (length(account_name) <= 200),
|
|
refresh_nonce text not null,
|
|
refresh_ciphertext text not null,
|
|
access_nonce text,
|
|
access_ciphertext text,
|
|
access_expires_at timestamptz,
|
|
updated_at timestamptz not null default now()
|
|
);
|
|
|
|
create table if not exists railyard.ship_link_sessions (
|
|
id_hash text primary key check (id_hash ~ '^[0-9a-f]{64}$'),
|
|
org_id uuid not null references railyard.orgs (id) on delete cascade,
|
|
app text not null check (app ~ '^[a-z0-9][a-z0-9-]{0,39}$'),
|
|
repo_full_name text not null,
|
|
installation_id bigint,
|
|
pkce_verifier text not null check (length(pkce_verifier) between 43 and 128),
|
|
state text not null default 'started' check (state in ('started', 'github_done', 'linked', 'failed')),
|
|
message text check (message is null or length(message) <= 500),
|
|
link_id uuid references railyard.ship_links (id) on delete set null,
|
|
expires_at timestamptz not null,
|
|
created_at timestamptz not null default now()
|
|
);
|
|
create index if not exists ship_link_sessions_expires_idx on railyard.ship_link_sessions (expires_at);
|
|
|
|
alter table railyard.github_installations enable row level security;
|
|
alter table railyard.ship_links enable row level security;
|
|
alter table railyard.cloudflare_connections enable row level security;
|
|
alter table railyard.ship_link_sessions enable row level security;
|
|
|
|
do $$
|
|
begin
|
|
if exists (select 1 from pg_roles where rolname = 'anon') then
|
|
execute 'revoke all on railyard.github_installations, railyard.ship_links, railyard.cloudflare_connections, railyard.ship_link_sessions from anon';
|
|
end if;
|
|
if exists (select 1 from pg_roles where rolname = 'authenticated') then
|
|
execute 'revoke all on railyard.github_installations, railyard.ship_links, railyard.cloudflare_connections, railyard.ship_link_sessions from authenticated';
|
|
end if;
|
|
if exists (select 1 from pg_roles where rolname = 'service_role') then
|
|
execute 'grant all on railyard.github_installations, railyard.ship_links, railyard.cloudflare_connections, railyard.ship_link_sessions to service_role';
|
|
end if;
|
|
end $$;
|