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?18 Replies
Project ID:
9f227eaa-51ec-450e-88f6-3b2a43a02dd8
9f227eaa-51ec-450e-88f6-3b2a43a02dd8
I would strongly recommend you use postgres going forward
i've used postgres on many other projects, but this project seems like a perfect usecase for sqlite & railway volumes.
where is the volume mounted to
/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...
are you running migrations during build?
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.
the volume is not available during build
Solution
you think this will do it?
yep that's how I'd do it
k lemme try that
i'm dumb
nah you aren't the first, that's why I asked the team to put that in the docs
hot diggity
that worked
thanks man!
no problem
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
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