Migra a koigrid

Mueve tu stack desde AWS/Vercel/Railway/Render pieza a pieza — cada paso es reversible. Postgres migra casi sin downtime con replicación lógica (CDC): haces el cutover cuando el lag es 0.

1. Postgres

Simple: dump + restore. Casi sin downtime: la replicación lógica vuelca tu origen en koigrid en streaming; cutover con lag 0.

# 1) Create the managed database + get its URL
koigrid db create prod --version 16
DATABASE_URL="$(koigrid db connection <id> --json | jq -r .connection.uri)"

# --- Simple (dump + restore) ---
pg_dump "$SOURCE_URL" | psql "$DATABASE_URL"        # or: drizzle-kit migrate / prisma migrate deploy

# --- Near-zero-downtime (logical replication / CDC) ---
# a) on your SOURCE (e.g. RDS with rds.logical_replication=1):
#      CREATE PUBLICATION mig FOR ALL TABLES;
# b) copy the SCHEMA to koigrid first (tables must exist):
pg_dump --schema-only "$SOURCE_URL" | psql "$DATABASE_URL"
# c) on koigrid (the app user has REPLICATION — no superuser needed):
#      CREATE SUBSCRIPTION mig CONNECTION 'postgresql://user:pass@source-host:5432/db' PUBLICATION mig;
# d) watch lag → 0:   SELECT * FROM pg_stat_subscription;
# e) cut over (point the app at koigrid), then:  DROP SUBSCRIPTION mig;

2. Almacenamiento (S3)

Tu bucket ya habla S3 — copia los objetos con rclone o aws-cli y reapunta el endpoint + claves de tu cliente.

koigrid storage buckets create assets
koigrid storage keys                     # → accessKey / secretKey / endpoint (shown once)

# copy objects from your old S3 (rclone remote 'koigrid' → https://s3.koigrid.com, path-style)
rclone copy s3old:my-bucket koigrid:assets

# then repoint your S3 client: endpoint=https://s3.koigrid.com, forcePathStyle=true,
# new keys, and use the bucketName koigrid returns (not the friendly name).

3. App

Despliega desde un repo git, una imagen de contenedor, o tu carpeta local (--dir, sin git ni Docker). Fija env vars y luego un dominio propio.

# from a git repo (add --repo-token for a private repo):
koigrid apps deploy web --repo https://github.com/you/app
# ...or straight from your local folder (no git, no Docker):
koigrid apps deploy web --dir ./

# env vars (invalid lines are reported, not fatal; saved even before the first deploy):
curl -X POST $API/apps/<id>/env -H "Authorization: Bearer koi_KEY" \
  -d '{"env":{"DATABASE_URL":"...","API_KEY":"..."}}'

# custom domain + automatic TLS:
koigrid apps domains web app.yourdomain.com

4. Cron jobs

Tus endpoints de EventBridge/cron pasan a jobs HTTP — koigrid pega a la URL según el cron con tu cabecera secreta.

# an EventBridge/cron endpoint → an HTTP job (koigrid calls the URL on schedule):
koigrid jobs create nightly --schedule "0 3 * * *" \
  --url https://app.yourdomain.com/api/cron/report --header "x-cron-secret: $SECRET"

# ...or a container job:
koigrid jobs create backup --schedule "0 2 * * *" --image alpine --command "sh -c '…'"

5. Cutover

Apunta el DNS a koigrid con rollback preparado. El tráfico va incluido y en tarifa plana — sin sorpresa de egress al salir de AWS.

# point your DNS at koigrid, keep the old stack ready to roll back.
# bandwidth is included + flat — no egress bill on the way out of AWS.