OP-1436 Sync load_demo_data.sql with the a118-a122 schema - #1654
OP-1436 Sync load_demo_data.sql with the a118-a122 schema#1654giuseppesorge wants to merge 2 commits into
Conversation
The step_a118 (DELETED_BY/DATE audit columns), a119 (deleted-movement log tables), a120 (user-related unique constraints), a121 (DECIMAL/INT precision) and a122 (password-lease columns) migrations are on develop, but the demo dump was never regenerated for them. As a result loading load_demo_data.sql into a clean database and starting the application fails with 'Unknown column ...us_deleted_by...'; CI does not catch it because it builds the schema from the step scripts, not from the demo dump. Regenerated the affected tables via a MariaDB round-trip (load the current dump, run a118-a122, dump the changed tables) so the schema matches and existing rows keep real values.
With the OP-896 password-idle check (Login: lastLogin + PASSWORDIDLE < now), the hardcoded US_LAST_LOGIN of '2026-01-15' in the demo admin row trips the 'account has not been used in N days' lock on any database loaded after that window. A fresh demo has nobody logged in yet, so NULL (the natural 'never logged in' state, which skips the idle check) is correct and never goes stale.
|
This one is a decision rather than a conflict to resolve, so I stopped before touching it.
What is left of this PR is two tables the dump does not contain, So either this PR is closed, or it is reduced to just adding those two tables, which would also make it reviewable. Happy to do whichever you prefer. |
What
sql/load_demo_data.sqlis a self-contained mysqldump used to load a clean demo database. Thestep_a118–a122migrations are on develop, but the demo dump was never regenerated for them:*_DELETED_BY/*_DELETED_DATEaudit columns (admission, supplier, patient, user, usergroup)OH_MEDICALDSRSTOCKMOV_LOG,OH_MEDICALDSRSTOCKMOVWARD_LOG)DECIMAL(19,2)/INTprecision on bills, prices and stock/medical quantitiesOH_USERAs a result, creating a clean DB, loading
load_demo_data.sqland starting the app fails at startup with:CI does not catch this because it builds the schema from the incremental step scripts, not from the demo dump — only the manual create docker db + load demo data flow is affected.
How
a118–a122→ dump the changed tables), so the demo dump schema matches the migration chain while existing rows keep real values. Only the 17 tables the migrations touch (plus the 2 new log tables) change; the other 47 are byte-identical.adminuser'sUS_LAST_LOGIN. With the OP-896 password-idle check (login refused when lastLogin + PASSWORDIDLE < now), the hardcodedUS_LAST_LOGINof2026-01-15idle-locks the admin account on any DB loaded after that window.NULLis the natural "never logged in" state for a fresh demo and skips the check, so it never goes stale.Scope note
The bulk of the diff comes from a121: switching the quantity/amount columns to
DECIMAL/INTreformats every bills / stock / medical data row. The startup crash itself only needs a118 + a122. Happy to narrow this PR to just the startup-fix subset if you'd prefer a smaller diff, or to keep the full a118–a122 sync — your call.Testing
Loaded the regenerated
load_demo_data.sqlinto a fresh MariaDB 10.6: loads with no errors, the previously-failingoh_userstartup query succeeds, all demo rows preserved (e.g. 525 patients), and the admin account no longer idle-locks.Fixes the startup failure reported on #1642.