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
?71 Replies
Project ID:
e12ed2b1-36ad-49bb-889a-b3a17a8dfd39
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
Hi @Brody , yeah please! If you share some steps I can try! thanks in advance.
for sure, lets walk through it, can you show me a screenshot of your project so i know what we are working with
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 wellhow where you trying to attach the screenshot before?
copy and paste! it works only uploading the file from my directory
odd
is that a staging env?
yes, I applied the migration to my staging before to move to prod.
you deleted the legacy database in that env?
no yet!
where is it?
ah cropped screenshot
cant tell too good whats going on with the blur unfortunate
looks like you have two legacy postgres databases?
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.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
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?
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.
fair enough, we will cross that bridge when we get to it
you can go ahead and delete the new staging db
on it! ...
done!
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 defaultis this normal to have been deployed into a different namespace?
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)done!
doesnt look like you have deployed it just yet, make sure to click the deploy button at the bottom middle of your screen
got it! deploy in progress...
done!
wanna remove those stray volumes? when deleting a service the volume is not deleted along with the service
gotcha! I just removed them and renamed the Postgres to my convention name
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 logson it..
aside of some messages in red color it seems it worked fine! what do you think?
oh yeah those are just warnings, nothing wrong with them
I see data in the tables too hehe
everything look good with the data?
Yeah data looks good so far!
cool, you can delete the migration service
deleted!
does your
megashop-staging
service use referance variables?yeah, but now it has some uuid values inside 🤔 . I think I should remove those ones right?
nope, dont touch them just yet
are those all the environment names that you use in code?
at least for db connection.. yes
perfect, just needed to know that, then from within the raw editor, replace all those uuid values with
megashop-db-staging
and savein progress..
like this right?
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
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!
awsome, all is good?
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!
great, let me know if anything goes wrong with that
for sure! thanks bro! I will keep you updated once I move to prod and execute the same steps you teached me!
sounds good
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?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 🤔was this an issue with the staging database and staging app?
yeah I just confirmed same happened on staging, unfortunately I did not catch it before to move to prod
where are you doing these actions with the database?
Using the web application which update the db data
from within railway?
yup, the service
megashop-prod
is a rails application into railwaypersonally 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)
I meant my web application, which is an admin panel to create categories, etc
can you show me some screenshots of that interface
It's my custom web app, a rails web application which uses in the background the postgres db
megashop-prod
is interacting with megashop-prod-db
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?
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!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
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!
happy to help! and im glad it all worked out for you!!