← All articles

Changing a MySQL database without unnecessary production risk

Plan columns, indexes and migrations with realistic data, compatible application code and checks for locking behaviour.

Adding a field seems small until the table contains millions of rows and the application writes continuously. The risk is not only whether the SQL is valid. It is what the operation may block, how much space it needs and whether old and new application versions can coexist during the change.

Split the change into compatible steps. Check the specific DDL operation for the installed MySQL version and rehearse it with representative data volume.

Start with the operation, not the online label

InnoDB supports different algorithms for different schema changes. Availability depends on the version, operation and table constraints. Online does not universally mean lock-free. Check the documentation and long transactions that may hold metadata locks, changing when the operation can proceed and how other requests behave.

Expand, migrate, then remove

For an important field rename, consider adding a new column first, deploying compatible code and moving data in batches. Remove the old field separately after checking reads and writes. Rolling back application code becomes difficult when it no longer understands the schema. The exact sequence must follow the actual consistency requirements.

Measure more than migration duration

Observe free space, waiting, transactions and the effect on critical queries. An index improves particular reads while adding write work and storage. Rehearsal should use realistic data and concurrent activity rather than an empty local table. Establish the baseline before the change so improvements and regressions can be distinguished.

Account for data arriving during the change

A backfill needs a progress marker and a way to resume after interruption. Consider records changed between reading and updating them. For sensitive business values, define how results are reconciled and discrepancies handled. A processed-row counter alone cannot establish that the final state is correct.

Finish with verification and recoverability

Check constraints, important record counts and contents, and representative reports. A pre-migration backup is useful, but restoring it over production can lose newer data. MSS can plan the database change together with application compatibility, validation and a realistic recovery path, rather than treating the migration as an isolated SQL file.

Documentation and sources

What should your software do better?

Describe the task, the system or the idea. We will clarify the scope and propose the next steps.

Call us · +359 89 341 4446

If we miss your call, expect a call back within 2 hours.

Prefer to write?