Convert JSON storage to SQLite #3

Merged
jose merged 7 commits from sqlite-storage into master 2026-07-29 11:40:59 +00:00
Owner
No description provided.
jose added 6 commits 2026-07-24 13:10:54 +00:00
Introduce better-sqlite3 and a schema-init module so we can migrate off JSON storage without changing runtime behavior yet.
Mirror the JSON repository API on SQLite without switching callers; clarify that SQLite is the storage backend and there is no JSON data migration.
Point routes, scheduler, and push service at fcmTokensSqlite so the service no longer reads or writes the JSON store.
Drop the upsert pre-read, project only needed columns, and add a (user_id, fcm_token) index for token lookups and dedupe deletes.
Delete the unused JSON storage implementation now that SQLite is the sole persistence backend.
Update README and .env.example for the SQLite database location, schema overview, backup/WAL notes, and clarify that JSON data is not migrated.
trentlarson reviewed 2026-07-25 23:08:21 +00:00
src/db/sqlite.ts Outdated
@@ -0,0 +4,4 @@
const dataDir =
process.env.FCM_TOKEN_DATA_DIR ?? path.join(process.cwd(), "data");
const dbFile = path.join(dataDir, "fcm-tokens.sqlite");
Owner

Let's make this DB a generic name for all wakeup notification purposes, eg. "notify.sqlite"

Let's make this DB a generic name for all wakeup notification purposes, eg. "notify.sqlite"
Author
Owner

I renamed the database file accordingly.

I asked AI about also changing the name to FCM_TOKEN_DATA_DIR (as a what-if), and it brought up good points for and against. I'm curious what your thoughts are on it?

I renamed the database file accordingly. I asked AI about also changing the name to FCM_TOKEN_DATA_DIR (as a what-if), and it brought up good points for and against. I'm curious what your thoughts are on it?
Owner

I'm not clear on that... it sounds like you are saying that it would be "FCM_TOKEN_DATA_DIR.sqlite", but it seems odd to put a "_DIR" name on the file.

Maybe you mean to have another environment variable like FCM_TOKEN_DATA_FILENAME, so the full change would be something like this:

const dataDir = process.env.FCM_TOKEN_DATA_DIR ?? path.join(process.cwd(), "data");
const fileName = (process.env.FCM_TOKEN_DATA_FILENAME ?? "notify") + ".sqlite";
const dbFile = path.join(dataDir, fileName);

That seems reasonable, but my feeling is that it adds some complexity (eg. if people name it something else then the file is harder to find) and it doesn't seem like the benefit of flexibility is worth it.

Or maybe you meant something else.

I'm not clear on that... it sounds like you are saying that it would be "FCM_TOKEN_DATA_DIR.sqlite", but it seems odd to put a "_DIR" name on the file. Maybe you mean to have another environment variable like FCM_TOKEN_DATA_FILENAME, so the full change would be something like this: ``` const dataDir = process.env.FCM_TOKEN_DATA_DIR ?? path.join(process.cwd(), "data"); const fileName = (process.env.FCM_TOKEN_DATA_FILENAME ?? "notify") + ".sqlite"; const dbFile = path.join(dataDir, fileName); ``` That seems reasonable, but my feeling is that it adds some complexity (eg. if people name it something else then the file is harder to find) and it doesn't seem like the benefit of flexibility is worth it. Or maybe you meant something else.
Author
Owner

Ahh sorry, I bungled the wording on that last reply. I meant "…changing the name of FCM_TOKEN_DATA_DIR" (the name of the environment variable that specifies the directory where notify.sqlite resides).

Ahh sorry, I bungled the wording on that last reply. I meant _"…changing the name **of** FCM_TOKEN_DATA_DIR"_ (the name of the environment variable that specifies the directory where notify.sqlite resides).
jose added 1 commit 2026-07-27 08:54:04 +00:00
Use a generic database filename for future notification-related storage, and update docs and env comments to match.
jose merged commit d8989f587e into master 2026-07-29 11:40:59 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: trent_larson/notification-wakeup-service#3