9 days ago
so am trying to run a migration and a seed.ts afterwards to seed and migrate my db service (postgress) and i do not know how to do that since there is no terminal in the web app or anything like that
9 Replies
9 days ago
hey,
u can run migrations as part of your deployment process , run migrations in your start script
modify your package.json to run migrations before starting your app:
{
"scripts": {
"start": "bun run migrate && bun run seed && bun run index.ts",
"migrate": "bun run drizzle-kit migrate",
"seed": "bun run seed.ts"
}
}in Railway:
set your start command to: bun run start (to set start command in Railway: settings → deploy → custom start Command → bun run start
this automatically runs migrations → seeding → starts your app on every deploy
lmk if it works
9 days ago
also make sure:
-DATABASE_URL is set in Railway environment variables
-Your drizzle.config.ts points to process.env.DATABASE_URL
- Your seed.ts checks if data exists before inserting (to avoid duplicates on redeployment)
9 days ago
no problem! let me know if it works or if you run into any issues with the setup
uhh so the commands didn't work because i was using a postges standard template but i needed the geometry one postgis for it to work so am trying again
9 days ago
You can also run your migration commands in a pre-deploy command.
https://docs.railway.com/guides/pre-deploy-command
Status changed to Solved medim • 7 days ago
