What is a database migration and how to apply it without losing information?
Published on 2026-10-26 by frfrand
Schema migrations: columns, indexes, compatible changes, backups, and rollback.


A database migration is a controlled change to the structure or certain data of a database, performed in a reproducible manner. It can add a column, modify an index, or transform information that a new version of the program needs.
A simple way to understand it
Imagine a customer record that until yesterday only stored name and email. Now you want to store their preferred language. Adding that field is simple in a small example, but in a database used by thousands of people, you have to consider previous versions and existing data.
How it works in practice
Frameworks like Django and SQL tools use migration files that describe ordered changes. The system knows which migrations were applied. Some changes require separating the introduction of a column from its filling and from the subsequent requirement of non-null values, to avoid blocking an old application.
What it does not solve and its limits
Not all migrations are reversible or instantaneous. Changing the type of a huge column or creating a certain index can block writes, consume space, or take longer than expected. A code rollback does not automatically undo a data transformation. Operations depend on the engine used.
How to apply it and verify it without surprises
Test the migration with a volume similar to the real one, perform verifiable backups, and observe lock times. If old and new instances will run simultaneously, design compatible changes. After deployment, verify real queries, metrics, and recovery capability.
How does it appear in ArduMaker?
When running PostgreSQL and an application on an ArduMaker VPS, migrations are part of the software publishing process and require coordination with backups and versions. The platform does not automatically decide schema compatibility.
The expand and contract pattern
A common method for compatible migrations consists of first adding new fields without removing old ones, publishing code capable of working with both formats, migrating records, and only then removing the old structure. This allows different versions to coexist for a while without blocking users.
A copy is not a recovery
Before an important change, check where the backups are and how long it would take to restore them. If you have thousands of transactions per hour, losing several hours of data may be unacceptable. Define recovery objectives, test the process, and document the steps; a correct migration also contemplates what to do when it fails halfway.
To remember
A database migration is a controlled change to the structure or certain data of a database, performed in a reproducible manner. Understanding when it applies, how it fails, and what data to review is more useful than memorizing isolated commands.
To expand: Django: Migrations.