Some checks failed
Run Tests / test (push) Failing after 5m2s
- Introduced a new template for currency overview and management (`currencies.html`). - Updated footer to include attribution to AllYouCanGET. - Added "Currencies" link to the main navigation header. - Implemented end-to-end tests for currency creation, update, and activation toggling. - Created unit tests for currency API endpoints, including creation, updating, and activation toggling. - Added a fixture to seed default currencies for testing. - Enhanced database setup tests to ensure proper seeding and migration handling.
2.1 KiB
2.1 KiB
Setup Script Idempotency Audit (2025-10-25)
This note captures the current evaluation of idempotent behaviour for scripts/setup_database.py and outlines follow-up actions.
Admin Tasks
- ensure_database: guarded by
SELECT 1 FROM pg_database; re-runs safely. Failure mode: network issues or lack of privileges surface as psycopg2 errors without additional context. - ensure_role: checks
pg_roles, creates role if missing, reapplies grants each time. Subsequent runs execute grants again but PostgreSQL tolerates repeated grants. - ensure_schema: uses
information_schemaguard and respects--dry-run; idempotent when schema ispublicor already present.
Application Tasks
- initialize_schema: relies on SQLAlchemy
create_all(checkfirst=True); repeatable. Dry-run output remains descriptive. - run_migrations: new baseline workflow applies
000_base.sqlonce and records legacy scripts as applied. Subsequent runs detect the baseline inschema_migrationsand skip reapplication.
Seeding
seed_baseline_dataseeds currencies and measurement units with upsert logic. Verification now raises on missing data, preventing silent failures.- Running
--seed-datarepeatedly performsON CONFLICTupdates, making the operation safe.
Outstanding Risks
- Baseline migration relies on legacy files being present when first executed; if removed beforehand, old entries are never marked. (Low risk given repository state.)
ensure_databaseandensure_roledo not wrap SQL execution errors with additional context beyond psycopg2 messages.- Baseline verification assumes migrations and seeding run in the same process; manual runs of
scripts/seed_data.pywithout the baseline could still fail.
Recommended Actions
- Add regression tests ensuring repeated executions of key CLI paths (
--run-migrations,--seed-data) result in no-op behaviour after the first run. - Extend logging/error handling for admin operations to provide clearer messages on repeated failures.
- Consider a preflight check when migrations directory lacks legacy files but baseline is pending, warning about potential drift.