fix/create-and-migrate-db-on-run #21

Merged
javif89 merged 2 commits from fix/create-and-migrate-db-on-run into next 2026-07-03 01:24:03 +00:00
Owner

Summary

I was already using SQLx’s migrate! macro and create_if_missing option at startup lol. But there were a few little fixes missing.

Closes #13

Added

  • Creates the data directory if it doesn't exists before opening SQLite.
  • Propagates database setup and migration errors with path context instead of the previous panic with the "Failed lol" message.
  • Completes database initialization before starting daemon/UI threads.
  • Adds tests for fresh setup, repeated migrations, and directory failures.

Other changes

  • Switched .env to have SQLX_OFFLINE=true so that we don't need a migrated dev database to compile since we now use the generated metadata in .sqlx anyway.
## Summary I was already using SQLx’s `migrate!` macro and `create_if_missing` option at startup lol. But there were a few little fixes missing. Closes #13 ## Added - Creates the data directory if it doesn't exists before opening SQLite. - Propagates database setup and migration errors with path context instead of the previous panic with the "Failed lol" message. - Completes database initialization before starting daemon/UI threads. - Adds tests for fresh setup, repeated migrations, and directory failures. ## Other changes - Switched `.env` to have `SQLX_OFFLINE=true` so that we don't need a migrated dev database to compile since we now use the generated metadata in `.sqlx` anyway.
javif89 requested review from xbazzi 2026-07-03 00:59:25 +00:00
xbazzi approved these changes 2026-07-03 01:23:25 +00:00
xbazzi left a comment

lgtm

lgtm
@ -347,3 +347,2 @@
let directory = tempfile::tempdir().expect("temporary database directory");
let database_url = format!("sqlite://{}", directory.path().join("waycast.db").display());
let database = WaycastData::writeable_connection(database_url).await;
let database = WaycastData::writeable_connection(directory.path().join("waycast.db"))
Collaborator

remove magic temporary

remove magic temporary
Collaborator

nvm it's just a test

nvm it's just a test
javif89 marked this conversation as resolved
javif89 deleted branch fix/create-and-migrate-db-on-run 2026-07-03 01:24:04 +00:00
Sign in to join this conversation.
No description provided.