Help with SQLite DB on volume

2 years ago

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?

24 Replies

2 years ago

9f227eaa-51ec-450e-88f6-3b2a43a02dd8


2 years ago

I would strongly recommend you use postgres going forward


2 years ago

i've used postgres on many other projects, but this project seems like a perfect usecase for sqlite & railway volumes.


2 years ago

where is the volume mounted to


2 years ago

/app/data


2 years ago

when i run locally the db ends up in /data/history.db


2 years ago

although the volume seems semi irrelevant


2 years ago

it's not between deploy persistence that's causing problems


2 years ago

it's just accessing the db in the deployed app that's not working correctly...


2 years ago

are you running migrations during build?


2 years ago

yup


2 years ago

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.


2 years ago

the volume is not available during build


2 years ago

you think this will do it?

1226343965930950788


2 years ago

yep that's how I'd do it


2 years ago

k lemme try that


2 years ago

i'm dumb

1226344246450323466


2 years ago

nah you aren't the first, that's why I asked the team to put that in the docs


2 years ago

hot diggity


2 years ago

that worked


2 years ago

thanks man!


2 years ago

no problem


Anonymous
TRIAL

2 years 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


2 years 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


Welcome!

Sign in to your Railway account to join the conversation.

Loading...