# Codex Agent Notes (app-master-back)

## Database schema changes

When updating `database/init.js` (creating tables, adding columns, indexes, etc.):

- Always add a matching Python migration script under `database/` (e.g. `database/migrate_*.py`) so changes can be applied immediately in production without relying on app startup.
- Keep the SQL in the Python script consistent with the SQL in `database/init.js`.
- Prefer **idempotent** migrations:
  - `CREATE TABLE IF NOT EXISTS ...`
  - `ALTER TABLE ... ADD COLUMN ...` guarded by handling duplicate-column errors (`errno=1060`)

Current BabyNote migrations:

- `database/migrate_babynote_news_gallery_i18n.py`
- `database/migrate_board_notice_popup.py`
- `database/migrate_board_notice_last_seen.py`

## Backend delivery

- When backend work is completed and validated, commit and push the backend changes unless the user explicitly says not to.
- Do not include unrelated or pre-existing untracked files in backend commits.
