R
Railway8mo ago
goleary

Help with SQLite DB on volume

I have a nextjs app that uses prisma . my DATABASE_URL="file:./data/history.db" When i build I get this log: #12 23.50 4 migrations found in prisma/migrations #12 23.51 Applying migration 20240406185550_init #12 23.51 Applying migration 20240406190746_ #12 23.52 Applying migration 20240406190823_rename #12 23.53 Applying migration 20240406192811_rename_to_celsius #12 23.55 The following migration(s) have been applied: #12 23.55 migrations/ #12 23.55 └─ migration.sql #12 23.55 └─ migration.sql #12 23.55 └─ migration.sql #12 23.55 └─ migration.sql #12 23.55 All migrations have been successfully applied. When I run the app though i get this: The table main.WeatherRecord does not exist in the current database. If the database_url is being interpreted the same both during build and run why would I be getting this error? Is anyone else using SQLite via volume attached to their service?
Solution:
you think this will do it?
No description
Jump to solution
18 Replies
Percy
Percy8mo ago
Project ID: 9f227eaa-51ec-450e-88f6-3b2a43a02dd8
goleary
golearyOP8mo ago
9f227eaa-51ec-450e-88f6-3b2a43a02dd8
Brody
Brody8mo ago
I would strongly recommend you use postgres going forward
goleary
golearyOP8mo ago
i've used postgres on many other projects, but this project seems like a perfect usecase for sqlite & railway volumes.
Brody
Brody8mo ago
where is the volume mounted to
goleary
golearyOP8mo ago
/app/data when i run locally the db ends up in /data/history.db although the volume seems semi irrelevant it's not between deploy persistence that's causing problems it's just accessing the db in the deployed app that's not working correctly...
Brody
Brody8mo ago
are you running migrations during build?
goleary
golearyOP8mo ago
yup When i build I get this log: #12 23.50 4 migrations found in prisma/migrations #12 23.51 Applying migration 20240406185550_init #12 23.51 Applying migration `20240406190746 #12 23.52 Applying migration 20240406190823_rename #12 23.53 Applying migration 20240406192811_rename_to_celsius #12 23.55 The following migration(s) have been applied: #12 23.55 migrations/ #12 23.55 └─ migration.sql #12 23.55 └─ migration.sql #12 23.55 └─ migration.sql #12 23.55 └─ migration.sql #12 23.55 All migrations have been successfully applied.
Brody
Brody8mo ago
the volume is not available during build
Solution
goleary
goleary8mo ago
you think this will do it?
No description
Brody
Brody8mo ago
yep that's how I'd do it
goleary
golearyOP8mo ago
k lemme try that
goleary
golearyOP8mo ago
i'm dumb
No description
Brody
Brody8mo ago
nah you aren't the first, that's why I asked the team to put that in the docs
goleary
golearyOP8mo ago
hot diggity that worked thanks man!
Brody
Brody8mo ago
no problem
Slaven
Slaven8mo ago
Hi! I am thinking of using Sqlite for a project. And I wanted yo ask how you went around to not only connect your app to the Sqlite db in the volume, but also how you access it from a DB explorer (if you did something like this). In the docs it says "To access your files, you must do so via the attached service's mount point". But I am not entirely sure how to do so
Brody
Brody8mo ago
once you are using sqlite in a volume there is no way to access that sqlite file outside of railway, there is no database explorer for sqlite. I would highly recommend postgres instead, it will make the development process much easier because it can be accessed both privately and publicly
Want results from more Discord servers?
Add your server