Railway
Reylo Migrate on Railway
Run your migrations as your service's pre-deploy command:
const web = service("web", {
// ...
preDeploy: "npx reylo migrate deploy",
});Apply it to your project:
$ railway config applyIt runs between the build and the deploy, in a container of its own on your private network. A migration that fails stops the deploy.
Database
Set DATABASE_URL from your Railway database:
const db = postgres("postgres");
const web = service("web", {
// ...
env: { DATABASE_URL: db.env.DATABASE_URL },
});Builds
Run your build on a dry run of the deploy. Its type check then reads the schema the pre-deploy command leaves.
Railway's builds can't reach your private network. So give the web service your database's public URL, which Railway sets once the database's public networking is on:
const web = service("web", {
// ...
env: {
DATABASE_URL: db.env.DATABASE_URL,
DATABASE_PUBLIC_URL: db.env.DATABASE_PUBLIC_URL,
},
});Then name it on the dry run:
npx reylo migrate deploy --dry-run --url "$DATABASE_PUBLIC_URL" -- npm run buildOther images
A Next.js standalone build, or any image without your node_modules, has no reylo command. Copy it from Reylo's image, with your reylo directory:
COPY --from=ghcr.io/reylosql/reylo:0.8.3 /usr/local/bin/reylo /usr/local/bin/reylo
COPY reylo/ reylo/Copy .reylo.yaml too, if you have one. Then run it directly:
const web = service("web", {
// ...
preDeploy: "reylo migrate deploy",
});