# PostgreSQL to MySQL migration

The PostgreSQL `smartclean` database was copied into MySQL 8 on localhost, database `smartclean`, on 2026-11-11. The website configuration remains on PostgreSQL pending a switch-over decision.

All 21 source tables were recreated using the existing Laravel migrations. Migration-created seed records were replaced by the actual PostgreSQL records, including the original migration history. IDs, password hashes, CMS translations, JSON content, sessions, and relationships were retained. Auto-increment values account for both existing IDs and PostgreSQL sequence positions.

Verification compared every row using SHA-256 hashes with JSON key ordering and boolean representation normalized. All 47 source indexes, 16 foreign keys and column nullability were checked. MySQL may add supporting indexes for foreign keys. PostgreSQL and MySQL use engine-specific representations for boolean, JSON, sequences, and unsigned numeric types; the schema uses Laravel's MySQL equivalents.

The services, plans, sign-in and sign-up pages returned HTTP 200 when rendered against MySQL. OAuth provider consent flows were not exercised.

Private artifacts are under `storage/app/private/database-migration/20261111-141804/`:

- `postgres.dump`: PostgreSQL custom-format backup, made before the transfer.
- `verification.json`: per-table row counts and content hashes.

The reusable transfer script is `scripts/migrate-postgres-to-mysql.php`. It accepts a private JSON file containing `host`, `port`, `database`, `username`, and `password`. It refuses to overwrite a database containing tables and never changes the website's connection settings. Credentials must not be committed. The locally supplied destination settings are stored with mode 0600 under `storage/app/private/database-migration/mysql.json`.

Before a later website switch, pause application writes and queue workers, take a fresh backup and re-copy any data changed since this snapshot into a new empty destination. Verify again, update the environment database settings, refresh configuration and restart long-running workers. PostgreSQL must remain available for rollback; reverting after new writes in MySQL requires reconciling those writes.
