R
Railway16mo ago
Fragly

db file not carrying over to new deployment

i'm using better-sqlite3 it seems that the db file is just falling back to the last save I had before hosting on railway every time I make a new deployment but all updates made in the current deployment stays, just resets when I redeploy
13 Replies
Percy
Percy16mo ago
Project ID: b4d97cb6-a8a0-4eb4-a9b3-6a249948870d
Percy
Percy16mo ago
It looks like the issue is related to the database itself, and that the storage inside the railway containers is ephemeral. To preserve the application's data across deployments, you will need to set up logging for when the app is running in production, and add a simple API route which just returns a basic JSON. You can also try running an interactive console, like heroku run rails c.
⚠️ experimental feature
Brody
Brody16mo ago
This is expected, storage isn't persistent so the database is reset with every deployment
Fragly
Fragly16mo ago
is there a way I can make it persistent shy
Brody
Brody16mo ago
You'll want to use the mysql database, should be easy enough to swap out
Fragly
Fragly16mo ago
oh I see, sorry I'm very knew to online hosting how will that make it persistent?
Brody
Brody16mo ago
Those databases don't get wiped because the data is not stored in your project folder
Fragly
Fragly16mo ago
ooh alright, any config I have to do on the project itself or do I just add it like I would if I hosted it locally
Brody
Brody16mo ago
Railway can provide a mysql database for you, you just add it to your project, it will generate a set of variables, you use those variables to connect to the database
Fragly
Fragly16mo ago
🥴 that sounds confusing, I'll watch some tutorials on it thanks for your help Brody!
Brody
Brody16mo ago
nah don't worry, it's not much more complicated than sqlite
Fragly
Fragly16mo ago
ah alright :D
Brody
Brody16mo ago
Though it seems like you might be using an orm wrapper, I'm sure you can find a good orm wrapper for mysql too