Shumiland/Dockerfile.migrator
Vadym Samoilenko 79b24ef3d9
Some checks failed
CI / Type Check (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
Deploy / Build & Push Image (push) Has been cancelled
Deploy / Deploy to VPS (push) Has been cancelled
fix(migrator): replace payload migrate with direct psql runner
tsx@4.21.0 + Node.js v22 has two unfixable interop bugs:
- --import tsx/esm hook: importSyncForRequire fails on @/ path aliases
- tsx runner: @next/env has __esModule:true but no .default export → TypeError

Solution: run SQL migrations directly via psql (alpine + postgresql-client).
All migration files use IF NOT EXISTS guards so they're idempotent on re-run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 20:12:02 +01:00

15 lines
605 B
Text

# syntax=docker/dockerfile:1
# Migrator — runs SQL migration files via psql.
# Bypasses tsx/Node.js v22 importSyncForRequire + @next/env interop bugs.
# All migrations must be idempotent SQL (use IF NOT EXISTS / ADD COLUMN IF NOT EXISTS).
FROM alpine:3
RUN apk add --no-cache postgresql-client
WORKDIR /migrations
COPY migrations/ .
CMD ["sh", "-c", "\
for f in $(ls -v *.sql 2>/dev/null); do \
echo \"→ $f\"; \
psql \"$DATABASE_URL\" -v ON_ERROR_STOP=0 -f \"$f\" && echo \"✓ $f\" || echo \"⚠ $f (errors ignored — likely already applied)\"; \
done; \
echo '✓ migrations done'"]