Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local database content is reset on every production build #13115

Open
1 task
meadowingc opened this issue Jan 31, 2025 · 0 comments
Open
1 task

Local database content is reset on every production build #13115

meadowingc opened this issue Jan 31, 2025 · 0 comments
Labels
needs triage Issue needs to be triaged

Comments

@meadowingc
Copy link

Astro Info

Astro                    v5.1.10
Node                     v23.6.0
System                   Linux (x64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/tailwind
                         astro:db
                         @astrojs/db/file-url
                         astro-auth

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Hi! I'm trying to run a project in my own private server that uses only a local DB through astro:db. I noticed the following issue

  1. Build the project with ASTRO_DATABASE_FILE=file:database.db astro build creates the 'dist' folder as well as a database.db file with my db schema
  2. I can run the build project with HOST=0.0.0.0 PORT=4321 node ./dist/server/entry.mjs and I see the data being properly added to the database as expected
  3. When I pull a new version of my code and rebuild the project with the same command above then it seems a brand new database.db file is created and ends up overwriting the old file. In so doing I lose all my data.

What's the expected result?

I would expect the data be persisted when one rebuilds the project. I tried exploring the astro db push commands but these only seem to work when one is targeting a remote DB.

If Astro doesn't support running only with a local db then it should say so in the documentation.

A hacky workaround is to copy the original database somewhere else, then build, and then copy it back to the original location. Of course, this only works if there have been no schema changes 😄

Link to Minimal Reproducible Example

https://codeberg.org/meadowingc/astro-minimal-issue-db-cleared-on-build

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant