# טיוטה היסטורית: שער המעבר ל־Frankfurt

> טיוטת PR #52 — רשומה היסטורית. מקור: docs/platform/supabase-eu-region-cutover-2026-11-11.md · 7e0126e · 2026-11-11.
> בגרסה הציבורית הושמטו מזהים תפעוליים ופרטי חשבון אישיים. קובץ המקור נשמר במאגר.

> **Historical record:** For the latest verified state and remaining release gates, see [the 2026-11-20 migration update](/draft-europe-migration). Later evidence supersedes status statements below.

# LinkNodes Energy — Frankfurt region migration release gate (2026-11-11)

**Status: DATABASE COPY VERIFIED; APPLICATION CUTOVER BLOCKED. Not a production GO.**

This file documents the existing state and exact rollback-safe steps. It does **not**
authorize deletion, payment execution, UI changes, or weakening tenant isolation.

## Immutable scope

- Product Git repo: `LinkNodesEnergy/LinkNodesEnergy`; tested application SHA:
  `c0982ded08192dc9ea6b379efe7ab9bb89d073cd`.
- Supabase source (Singapore `ap-southeast-1`): `[project-ref-redacted]`.
- Supabase destination (Frankfurt `eu-central-1`): `[project-ref-redacted]`.
- Unrelated Car Dealers BMS Supabase project: `[project-ref-redacted]`; never touch.
- Vercel Product project: `[operational-id-redacted]`.
- Railway project: `[operational-uuid-redacted]` (production).
- Preserve approved UI, routes, design system, images, logos, authentication model,
  customer records, credentials, tenant IDs, and database access controls.

## Verified destination

- Both Supabase projects healthy. 43 / 43 application tables, 3,665 / 3,665
  records and matching row-content checksums on all 43 tables at initial copy.
- Exact metadata digests match: 70 application SQL functions, 43 RLS policies,
  43 user triggers, 123 indexes, 326 constraints, and 419 column definitions.
  All 54 app foreign-key relationships have zero orphaned records.
- Historical SQL from `supabase_migrations.schema_migrations` was used to
  recreate application structure; three **source-only destructive QA fixture
  cleanup migrations** were intentionally not run on the empty target.
- Two Supabase Vault secrets copied into encrypted target storage with matching
  hashes, without printing their values.
- `workspace-logos` bucket exists in both projects with matching private WebP
  constraints; source Storage has **zero objects** at inspection time.
- `lne-company-forms` Edge Function deployed to target, source/target
  SHA-256 `aa0b02799cc0505dff35adf783706921cc016f2cbd0040cd60beed3981fd81ac`,
  `verify_jwt=false` as originally configured; it validates origin and Turnstile
  before accepting a submission.
- Destination `linknodes-billing-renewals` and `lne-company-forms-retention`
  pg_cron jobs are **disabled** to avoid duplicate processing. The source jobs
  remain authoritative until cutover.
- A PostgreSQL-level JWT claim test showed authenticated owner access to
  one tenant/vehicle/membership, and zero for a nonmember. This is **not**
  evidence of actual Clerk issuer acceptance.
- Live source/target digest re-check on eight critical app tables found no
  drift at the time it ran. Re-run before switching, because source stays live.

## Runtime gate — fail closed

- Vercel website/product/admin runtime already pinned to `fra1`.
- Product Production env `NEXT_PUBLIC_SUPABASE_URL` still points to Singapore.
  Never change URL alone or leave it paired with a Singapore service key.
- Product **Preview** env has target Frankfurt URL and publishable key.
  Deployment `[operational-id-redacted]` was READY in `fra1`;
  the public product UI and `GET /api/health` returned 200, but a client
  API route returned **HTTP 503 PLATFORM_NOT_CONFIGURED**. Do not promote it.
- Clerk production session tokens include `role: authenticated`.
  Target Supabase third-party Clerk issuer trust is not verified/configured
  through available management tools; verify it in Supabase Authentication.
- The target Supabase **server-only** service-role/secret API key is not exposed
  by the connected Supabase tool. Provision it directly from the destination
  dashboard into Vercel's protected sensitive `SUPABASE_SERVICE_ROLE_KEY`
  setting; **never paste it in Git, chat, logs, client env or public output**.
- Before production, create a private verified-preview environment with Clerk
  secret, Frankfurt publishable key, URL and Frankfurt server-only secret;
  confirm real authenticated personal and organization account flows.
- Verify tenant A/B isolation for every protected read and write, RLS via real
  signed Clerk JWT, owner changes, onboarding, provider directory, existing
  tenant vehicle and account deletion request routes. Re-run negative tests.
- All source/target records, RPCs, RLS, Storage policies, extensions, Vault
  references and applicable CRON behavior must still agree before cutover.

## Cutover procedure — only after all gates pass

1. Confirm source backup is restorable; record the exact Vercel source Production
   deployment, current source data counts, latest migrations and source Cron jobs.
2. Freeze new writes/issuance briefly and replay/check any live data delta;
   re-verify all 43 tables using row checksums. Do not assume source did not change.
3. Stage a Vercel **production build without assigning customer domains**, with
   the target `NEXT_PUBLIC_SUPABASE_URL`, `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY`
   and **target**, never source, `SUPABASE_SERVICE_ROLE_KEY` supplied together.
   Verify required Clerk configuration and authenticated smoke.
4. Keep source scheduled jobs active until an atomic operational cutover window.
   Stop source billing Cron, activate matching target Cron exactly once, and
   check idempotency and no double charge. Retention Cron likewise switches
   only when target becomes authoritative.
5. Promote the verified Frankfurt Product deployment, verify the live domain
   alias and re-run signed authentication, forms, provider/vehicle/account flows,
   health, logs, and cross-tenant denials.
6. Observe production while maintaining the Singapore source for rollback.
   Rollback means restoring the old Vercel deployment/env + source Cron
   authority **and reconciling writes made after cutover**. Never silently
   overwrite or lose Frankfurt writes.
7. Delete Singapore only after a **separate restore-tested backup**, customer
   data reconciliation, operational signoff, and explicit decommission approval.
   Project deletion is irreversible and is not part of this checklist.

## Railway and Cloudflare

- Cloudflare DNS routes to Vercel/Clerk. No project Cloudflare Worker/D1/R2
  runtime must be relocated; keep edge DNS globally distributed.
- Railway Redis, BullMQ worker and runtime still **live in SFO**, despite
  Amsterdam region updates staged in patch
  `[operational-uuid-redacted]`.
- Redis's 500 MB persistent volume `redis-volume` remains in SFO.
  Railway region changes to volume-bearing services require volume migration,
  with potential downtime. **Verify a restorable backup and queue inventory
  before accepting the staged patch**. Do not detach/delete the old volume or
  deploy worker independently if it would lose private Redis connectivity.
- After a safe migration, verify the Railway environment has three healthy
  Amsterdam services, Redis persistence, BullMQ smoke job/health, no stalled
  jobs, and acceptable Vercel↔Railway↔Supabase latency.

## Change boundary

This document is a deployment control record only: no UI, code, asset,
DNS, production environment variable, data deletion or Railway deployment
changes are authorized by this document.

## Final verification update — same day

- Live source reads are mutable even before cutover. An updated `verified_at`
  value in the single `ev1_private.verified_member_emails` record caused
  checksum drift (one table, unchanged row count). Frankfurt was resynchronized
  from the authoritative Singapore record without changing its primary key.
  A subsequent full 43-table digest/row-count comparison returned **43/43
  exact matches, 3,665/3,665 rows**, and zero mismatches.
- Clerk production domain `product.linknodesenergy.com` reports domain,
  DNS and SSL **complete**; Clerk's session configuration contains
  `claims.role = authenticated`. This does NOT establish that the new
  Supabase project trusts this Clerk issuer.
- Frankfurt's official Supabase MCP connection exposes **publishable keys
  only**, not `sb_secret_...` or legacy `service_role` secrets. Do not
  derive or forge an elevated token from database internals. Create the
  Frankfurt project server secret through the official dashboard and inject
  it into a protected deployment, never the browser.
- Neither the currently connected Railway administration tool nor the
  connected Railway automation account exposes an operation to create,
  inspect, or restore a Redis volume backup. The Redis volume remains
  mounted in SFO (500 MB allocated, \~50 MB disk usage); online/healthy
  Redis with persisted disk does **not** prove an independently restorable
  backup. Keep the Amsterdam patch staged until native backup and restore
  evidence exist.
- In the Frankfurt-URL Vercel Preview, `GET /api/health` passes but
  the protected client endpoint returns `PLATFORM_NOT_CONFIGURED`. The
  application's `platformConfigured()` guard requires Clerk publishable,
  Clerk server secret, Supabase URL, and Supabase publishable key. Adding
  only the Frankfurt public URL/key cannot provide authenticated QA.
  Do not copy production Clerk secrets indiscriminately to all previews;
  restrict QA to a trusted environment or a staged production deployment.
- Railway's existing Amsterdam staged patch spans Redis + two BullMQ
  services, while the **live** volume is still in SFO. Do not apply patch
  until backup restore is verified and a coordinated cutover window exists.

### Account-side authorization to complete the blockers

1. Open Supabase Frankfurt project
   `https://supabase.com/dashboard/project/[project-ref-redacted]/auth/third-party`.
   Connect the existing production Clerk instance. The verified frontend
   API domain is `https://clerk.product.linknodesenergy.com`; confirm the
   issuer provided by Clerk rather than assuming a URL is a valid OIDC issuer.
2. Open Supabase Frankfurt API Keys:
   `https://supabase.com/dashboard/project/[project-ref-redacted]/settings/api-keys`.
   Create or retrieve a **server-only** `sb_secret_...` key; scope it
   to this project and save it directly as Vercel sensitive
   `SUPABASE_SERVICE_ROLE_KEY` in an isolated trusted QA environment.
   Never disclose the value via GitHub, chat, front-end envs or logs.
3. In Railway, select LinkNodes Energy Infrastructure → Redis →
   Backups. Create a named backup, verify completion and demonstrate a
   non-destructive restore in an isolated volume/service. Do not
   delete or overwrite the production volume.
4. After these prerequisites: signed-Clerk E2E tests, atomic Vercel
   target configuration switch, one-writer freeze/final digest, staged
   promotion, Cron handover, and Railway region migration with rollback.

**No production cutover or source-project deletion was performed.**
