Auto update postgres database with new main changes in backend

onestyle7
FREE

18 days ago

Hello, we are looking for solution to get auto database update while we provide new backend changes, like new entities with new migration. Today we did deploy new version of application, backend has new migration file but postgres doesnt auto update to that migration, how we could do it? Actually we need it so hard because today to get new verions we had to delete old database so we lost data. To sum it app, we are looking for solution to this case push changes on main -> Backend is building -> Postgres database is updating

$10 Bounty

10 Replies

Your app is responsible for managing migrations. What database library are you using?


onestyle7
FREE

17 days ago

I dont have problem with migrations, just update of postgres db here. I'm using postgres db, backend is in .net


I'm not sure what you mean by update then. Migrations do not require Postgres to do anything on it's own.


onestyle7
FREE

17 days ago

Like if i change backend and create new tables then i need it on DB but, DB is still with old ones without new ones. In migrations folder on backend exist migrations with new tables but posthres on railway dont use it to do database update


You're creating the tables wrong, then.


onestyle7
FREE

17 days ago

nah, all works corectlly locally, and then after we delete old db from railway and deploy again then all is good, but we cannot lost data everytime when we do changes in db


onestyle7

nah, all works corectlly locally, and then after we delete old db from railway and deploy again then all is good, but we cannot lost data everytime when we do changes in db

Are you saying that every time you redeploy the database you lose the data?


onestyle7
FREE

17 days ago

Actually i have to delete old db from railway, than deploy again anyway it doeasynt work


What do you mean "doesn't work"


onestyle7
FREE

17 days ago

so i will describe maybe all procces. We are doing virtual career advisor. We collect from the user some data, like work experience, education and some other stuff, in the new version we add forms with financial survey - which all works on locally db, corectly. We push changes to the develop branch and next make pull request develop -> main to deploy those changes in production. Then in logs we saw that there is problem with db
next we check Data -> "Tables" in railway and we saw there is no Table "FinancialSurvey" but this table exist in locall DB so migrations work corectly. Then we talk with Claude to find solution and it reccomend to delete old Postgres build and try to do new one - this solution work, but the problem is, we lost data from last DB (that's obvious) AND such database change/update doesn't happen automatically after adding changes to the main. If something is not clear then sory, we are just students and this is the first project we are releasing for production

Attachments


Auto update postgres database with new main changes in backend - Railway Help Station