R
Railway•10mo ago
Wildo

After migrate the database my application is not longer working.

I have running a ruby on rails 4.2 application on the service e12ed2b1-36ad-49bb-889a-b3a17a8dfd39 . My app uses gem pg, ~> '0.18.4' which is compatible with active record 4.2. The application crashed and the error displayed in the log is this one PG::ConnectionBad: SCRAM authentication requires libpq version 10 or above It's not viable for me to upgrade ruby on rails to a newer version to use a recent pg and active model gem at this time. Is there any configuration I can do on the database service to do not use scram and continue using the old md5 ?
No description
71 Replies
Percy
Percy•10mo ago
Project ID: e12ed2b1-36ad-49bb-889a-b3a17a8dfd39
Brody
Brody•10mo ago
the new database is postgres 15 where scram is the default, would you be intrested in a walk though on how to deploy postgres 13 and then re-do the migration? @Wildo tag for viz
Wildo
Wildo•10mo ago
Hi @Brody , yeah please! If you share some steps I can try! thanks in advance.
Brody
Brody•10mo ago
for sure, lets walk through it, can you show me a screenshot of your project so i know what we are working with
Wildo
Wildo•10mo ago
When trying to attach the screenshot I got Woah there! The owner of Railway has requested that Discord block any messages our mostly-accurate robots deem to be explicit, so your message has not been sent. but basically I have three services: the ruby on rails 4.2 app, the postgres db and a redis db as well
Wildo
Wildo•10mo ago
No description
Brody
Brody•10mo ago
how where you trying to attach the screenshot before?
Wildo
Wildo•10mo ago
copy and paste! it works only uploading the file from my directory
Brody
Brody•10mo ago
odd is that a staging env?
Wildo
Wildo•10mo ago
yes, I applied the migration to my staging before to move to prod.
Brody
Brody•10mo ago
you deleted the legacy database in that env?
Wildo
Wildo•10mo ago
no yet!
Brody
Brody•10mo ago
where is it?
Wildo
Wildo•10mo ago
No description
Brody
Brody•10mo ago
ah cropped screenshot cant tell too good whats going on with the blur unfortunate looks like you have two legacy postgres databases?
Wildo
Wildo•10mo ago
the legacy is the one labeled with megashop-db-staging Le in the screenshot. The new one is megashop-db-staging the other one is redis. The legacy and the new one.
Brody
Brody•10mo ago
im seeing 3 total postgres databases, two legacy, one new if you would be okay sending a screenshot without the blur, its making things a bit confusing
Wildo
Wildo•10mo ago
No description
Brody
Brody•10mo ago
thank you makes so much more sense now before we start, i assume everything went fine with redis? your app would have no problems with it?
Wildo
Wildo•10mo ago
Unfortunately I can't confirm that, because when trying to connect to the db during the initialization the app is crashing and redis is never called to start running.
Brody
Brody•10mo ago
fair enough, we will cross that bridge when we get to it you can go ahead and delete the new staging db
Wildo
Wildo•10mo ago
on it! ... done!
Brody
Brody•10mo ago
then deploy a template called Postgres 13 - PostGIS + TimescaleDB into the project, then you can name it accordingly this is going to be the closest to legacy, new database you can deploy, and i have confirmed it uses md5 for the passwords by default
Wildo
Wildo•10mo ago
is this normal to have been deployed into a different namespace?
No description
Brody
Brody•10mo ago
you may have deployed it from the dashboard, you want to deploy the template from the + New button in the top right of your already existing project you can delete that project, we need the database to be in the same project (what you're calling a namespace is called a project)
Wildo
Wildo•10mo ago
done!
No description
Brody
Brody•10mo ago
doesnt look like you have deployed it just yet, make sure to click the deploy button at the bottom middle of your screen
Wildo
Wildo•10mo ago
got it! deploy in progress... done!
Brody
Brody•10mo ago
wanna remove those stray volumes? when deleting a service the volume is not deleted along with the service
Wildo
Wildo•10mo ago
gotcha! I just removed them and renamed the Postgres to my convention name
No description
Brody
Brody•10mo ago
perfect deploy a new template called Postgres Plugin Migration into this project the PLUGIN_URL variable will be the DATABASE_URL variable's value from the legacy database the NEW_URL variable will the the DATABASE_PRIVATE_URL variable's value from the new database you just deployed click save and then deploy monitor its logs
Wildo
Wildo•10mo ago
on it..
Wildo
Wildo•10mo ago
aside of some messages in red color it seems it worked fine! what do you think?
No description
Brody
Brody•10mo ago
oh yeah those are just warnings, nothing wrong with them
Wildo
Wildo•10mo ago
I see data in the tables too hehe
Brody
Brody•10mo ago
everything look good with the data?
Wildo
Wildo•10mo ago
Yeah data looks good so far!
Brody
Brody•10mo ago
cool, you can delete the migration service
Wildo
Wildo•10mo ago
deleted!
Brody
Brody•10mo ago
does your megashop-staging service use referance variables?
Wildo
Wildo•10mo ago
yeah, but now it has some uuid values inside 🤔 . I think I should remove those ones right?
No description
Brody
Brody•10mo ago
nope, dont touch them just yet are those all the environment names that you use in code?
Wildo
Wildo•10mo ago
at least for db connection.. yes
Brody
Brody•10mo ago
perfect, just needed to know that, then from within the raw editor, replace all those uuid values with megashop-db-staging and save
Wildo
Wildo•10mo ago
in progress..
Wildo
Wildo•10mo ago
like this right?
No description
Brody
Brody•10mo ago
looks good to me once you save you can always double check that they render to what youd expect by clicking their eye icons your service will also re-deploy, so do let me know how that goes too
Wildo
Wildo•10mo ago
service is being re-deployed... that worked real good Brody! My app is working again, I did a quick test and the main workflow is working as expected!
Brody
Brody•10mo ago
awsome, all is good?
Wildo
Wildo•10mo ago
yeah, everything is working fine! In the morning I will do more testing before to move to prod! But so far it looks good! thanks, you are a rockstar!
Brody
Brody•10mo ago
great, let me know if anything goes wrong with that
Wildo
Wildo•10mo ago
for sure! thanks bro! I will keep you updated once I move to prod and execute the same steps you teached me!
Brody
Brody•10mo ago
sounds good
Wildo
Wildo•10mo ago
Hi @Brody hope you are well! I found an issue! It seems the new migrated db lose new changes applied after the migration done via the Postgres Plugin Migration. So, I update some records in the db then I restart the main service which uses the db, and the db now does not have last applied changes 🤔 Do you think is related to the volume attached to the db?
No description
No description
Wildo
Wildo•10mo ago
In another words, the db has a table called categories, I removed one category and updated one, that looks good at first time, however when I restart megashop-prod those changes are gone 🤔
Brody
Brody•10mo ago
was this an issue with the staging database and staging app?
Wildo
Wildo•10mo ago
yeah I just confirmed same happened on staging, unfortunately I did not catch it before to move to prod
Brody
Brody•10mo ago
where are you doing these actions with the database?
Wildo
Wildo•10mo ago
Using the web application which update the db data
Brody
Brody•10mo ago
from within railway?
Wildo
Wildo•10mo ago
yup, the service megashop-prod is a rails application into railway
Brody
Brody•10mo ago
personally i would never use the data tab, it is extremely unreliable, please use something like pgadmin or dbgate or even adminer (its also a template)
Wildo
Wildo•10mo ago
I meant my web application, which is an admin panel to create categories, etc
Brody
Brody•10mo ago
can you show me some screenshots of that interface
Wildo
Wildo•10mo ago
It's my custom web app, a rails web application which uses in the background the postgres db
No description
Wildo
Wildo•10mo ago
megashop-prod is interacting with megashop-prod-db
Brody
Brody•10mo ago
and you are absolutely sure this app is connected to the new staging database? when you add data via your web app, can you check the corresponding database for that data with dbgate or pgadmin?
Wildo
Wildo•10mo ago
it's so weird! I double checked, I can't reproduce in staging however it is happening in prod. Steps to reproduce 1. From my web application I destroyed/deleted two categories. I checked from pgadmin that they were deleted 2. I updated the code just to be able to push to github and trigger a new deploy 3. After the deploy is successfully finished, those two categories magically displayed as two rows again in the table 🤔 ohhh my bad! so sorry! It's a seed I run in each deploy that is inserting those records again. ufff my bad man!
Brody
Brody•10mo ago
sounds like you're running outdated migrations when the app is started. so not related to the migration or railway, but something your app is doing. unfortunately I have never touched rails so helping you with the migration on the railway side of things is about all the help I can provide here unfortunately well hey at least my guess was correct haha
Wildo
Wildo•10mo ago
yeahh it's all good with railway! sorry about that! I am preloading some categories on the start and even after removing of course next deploy those ones will be created if they dont exists! sorry Brody! all good thanks again Brother for the support! really appreciate it!
Brody
Brody•10mo ago
happy to help! and im glad it all worked out for you!!
Want results from more Discord servers?
Add your server