Database changes are part of application releases. Yii migrations provide a versioned way to describe schema changes, while fixtures help tests begin from known data.
Write focused migrations
A migration should make one coherent schema change and include a safe rollback when practical. Review generated SQL for indexes, foreign keys and data transformations. Large table changes may need a staged deployment plan.
Keep data migrations deliberate
Schema changes and bulk data transformations have different risk profiles. For large datasets, use resumable batches and progress tracking rather than a single long-running deployment transaction.
Use fixtures for tests
Fixtures should create only the records needed by a test and should avoid depending on production identifiers. Keep fixture relationships valid and reset test state predictably.
Deployment discipline
Back up the database, test migrations against a production-like copy and verify application compatibility during rollout. Do not assume that a successful migration on an empty database proves safety on a populated one.
Further reading
- Yii migrations: https://www.yiiframework.com/doc/guide/2.0/en/db-migrations
- Yii fixtures: https://www.yiiframework.com/doc/guide/2.0/en/test-fixtures