Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/development/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,13 @@ NENE_DB_TYPE=SQLite3 NENE_DB_FILE=nene.db docker compose up --build app

## Schema Parity Between SQLite and MySQL

NeNe initializes two separate development databases through two separate scripts:
NeNe initializes the sample database through **three** independent code paths:

- `cli/initSQLite.php` — PHP code that creates SQLite tables and `updated_at` triggers when the SQLite3 fallback is used.
- `docker/mysql/init/001_schema.sql` — declarative SQL applied by the MySQL container on first boot under Docker Compose.
- `cli/initSQLite.php` — legacy PHP CLI that creates SQLite tables and `updated_at` triggers. Maintained for backwards compatibility; new deployment guides should prefer `cli/setupDatabase.php`.
- `class/xion/DatabaseInstaller.php` — the generic installer invoked by `cli/setupDatabase.php`. Holds inline CREATE TABLE statements for both MySQL and SQLite paths. This is the canonical installation path.

These files **do not share a source of truth**. Nothing in CI enforces parity between them. When a contributor adds or alters a table, both files must be edited in the same change, and both runtimes must be verified locally.
These three sites **do not share a source of truth**. Nothing in CI enforces parity. When a contributor adds or alters a table, **all three** must be edited in the same change, and both runtimes verified locally.

When in doubt about whether the two paths agree, compare the table sets:

Expand Down
2 changes: 1 addition & 1 deletion docs/review/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Source policies:

## Checklist

- [ ] Schema changes are mirrored in **both** `docker/mysql/init/001_schema.sql` **and** `cli/initSQLite.php`. The two files do not share a source of truth; CI does not enforce parity.
- [ ] Schema changes are mirrored in **all three** locations: `docker/mysql/init/001_schema.sql`, `cli/initSQLite.php`, and `class/xion/DatabaseInstaller.php` (used by `cli/setupDatabase.php`). The three sites do not share a source of truth; CI does not enforce parity.
- [ ] SQLite path includes an `..._updated_at_trigger` to mirror MySQL's `ON UPDATE CURRENT_TIMESTAMP`.
- [ ] Foreign keys cascade-delete or restrict deliberately; the choice matches the entity lifecycle.
- [ ] Per-user tables expose `user_id` as a `BIGINT UNSIGNED` FK to `users.id`, indexed (`KEY ..._user_id_index`).
Expand Down