# Handover to Phase 02.2 — Migration Engine and Core Database Baseline

Release 02.01.00 provides a working PDO service and a private `database/migrations` directory but deliberately installs no schema.

## Required Release 02.02.00 work

1. Add a CLI migration runner with:
   - ordered migration IDs
   - SHA-256 migration checksums
   - database advisory locking to prevent concurrent runs
   - execution time and batch tracking
   - status, migrate and rollback commands
   - safe failure behavior and explicit non-reversible migration support

2. Create the initial normalized schema for:
   - schema migration history
   - organisations/tenants
   - users and user identities
   - roles and permissions
   - role-permission and user-role assignments
   - active/revoked user sessions
   - login attempts and lockout state
   - audit events
   - application/system settings

3. Establish database conventions:
   - InnoDB
   - `utf8mb4` with a server-compatible Unicode collation
   - UTC `DATETIME(6)` timestamps
   - unsigned bigint internal keys plus non-sequential public identifiers
   - foreign keys and explicit indexes
   - tenant-scoped uniqueness where applicable
   - no business-critical values stored only inside JSON

4. Add baseline seed data:
   - system roles
   - permission catalogue
   - required system settings
   - no default/shared production password

5. Extend readiness to verify the expected migration version.

## Inputs required from the deployed server

Before Release 02.02.00 is finalized, retain the output of:

```bash
/opt/cpanel/ea-php85/root/usr/bin/php /home/CPANEL_USER/examcert/bin/console app:check
/opt/cpanel/ea-php85/root/usr/bin/php /home/CPANEL_USER/examcert/bin/console db:check
mysql --version
```

The MySQL/MariaDB engine/version determines the safest collation, check-constraint and index syntax.
