Sveltekit SQLite Migrations Volume
howesc
HOBBYOP

a year ago

https://github.com/howesc/sveltekit-sqlite

Hello! Please help me, attempting the following:

  • Deploy Sveltekit app via Dockerfile

  • Store SQLIte DB on persistent volume

  • Apply DB migrations during deployment

I've got close but no cigar. According to the build logs the /migrate script runs fine - the script creates a users table. However according to the app logs, the app cannot see the users table. I think the migration script and app might be looking at two different locations, although within the app they both reference the same path "./vol/db.sqlite".

From build log: #13 0.138 database path: vol/db.sqlite

From app log: SqliteError: no such table: user

Solved

3 Replies

brody
EMPLOYEE

a year ago

You're running your migrations during build.

The volume is not mounted during build.

Run your migrations during runtime before starting your app.


howesc
HOBBYOP

a year ago

Awesome, you're a legend!

I did this:

Remove from Dockerfile:

# RUN mkdir vol
# RUN node migrate

Modify package.json:

"start": "node migrate && node build"

brody
EMPLOYEE

a year ago

Perfect, thank you for following backup with the exact solution that worked for you!


Status changed to Solved brody about 1 year ago


Loading...