Laravel Migration Safety for Production
Treat a production migration as a coordinated database and application change, not just an Artisan command. Rehearse on representative data, preserve compatibility during rollout, confirm a recoverable backup and verify the schema and business writes before cleanup.
A safe Laravel production migration starts before the release window. Identify what the schema change will lock or rewrite, which running code expects the old shape, and what happens to customer writes if recovery becomes necessary. A successful command is only one piece of evidence: the application must also read and write correctly against the resulting schema.

Review the change as a database operation
Rehearse migrations against representative data and keep old and new application versions compatible during rollout. Check locking and real application writes; a successful migration command alone is not acceptance.
List every migration in release order and name the target database, connection, tables, indexes and constraints. Review the generated SQL for the actual database engine and version rather than assuming that Laravel's database-agnostic schema API makes execution costs identical. On the intended release and connection, php artisan migrate:status shows Laravel's migration history; php artisan migrate --pretend previews generated statements. The preview is not a safety proof: custom migration code and the actual state of the target still need review. The Laravel migration documentation describes these commands and execution options.
For each statement ask whether it scans or rewrites a large table, validates existing data, builds an index, waits for a lock, or prevents reads or writes. Existing long-running transactions may make a brief-looking change wait much longer. PostgreSQL documents the conflicts between lock modes and notes that many forms of ALTER TABLE can acquire an access-exclusive lock; other database engines have different rules. Consult the PostgreSQL locking reference or your engine's equivalent for the exact operation and version.
Record the maximum acceptable impact and a stop decision before execution. Choose engine-specific lock and statement limits only after testing their behavior; a timeout may stop waiting, but it is not a substitute for understanding what already committed. Include replication, disk space, transaction logs, backups, and concurrent scheduled work in the assessment. Identify a person who can stop the rollout and another who can make the business decision about data recovery.
Rehearse with realistic data and a recovery point
Restore a recent, suitably protected and de-identified production-like dataset into an isolated environment with the same engine major version and comparable schema, indexes and configuration. Use a dataset large and varied enough to reveal nulls, duplicate keys, unusually long values and hot tables. Rehearse with representative reads, writes and worker activity rather than timing the migration on an empty database. Avoid copying customer secrets into a broadly accessible test environment.
Measure lock waiting, runtime, disk headroom, replication lag and application errors throughout. Note the precise revision, migration output and environment so another operator can repeat the rehearsal. If the test environment has different hardware or traffic, treat its timing as an observation, not a production guarantee. Investigate failed validation or unexpected blocking before proceeding; do not simply enlarge the release window.
Before production, confirm the backup is recent enough for the business recovery objective and that a restore has actually been exercised. PostgreSQL explains that a database dump is a consistent snapshot, but restoring it requires a suitable target and appropriate owners and privileges. Determine whether roles, other databases, uploaded files, queue state and external side effects need separate recovery. Restoring over a live database is destructive: writes made after the recovery point can be lost, and replay or reconciliation needs a specific plan.
For a large production table, include realistic competing transactions in the rehearsal and capture both lock acquisition time and the time the lock is held. Review the database documentation for the precise alteration: an online schema change mechanism may still need brief metadata locks, extra disk space, replication capacity or a final cutover. Its guarantees and failure handling vary by engine and tool. Rehearse cancellation, cleanup of any intermediate objects, and resumption on the isolated copy before proposing it for production. Compare the generated SQL from --pretend with the migration code itself, since a preview cannot establish execution time or reproduce production contention.
Expand, transition, then contract
Prefer changes that keep old and new application releases working during the overlap. Add a nullable field or a new table first; deploy code that understands the transition; backfill existing rows in controlled, resumable batches; verify consistency; then switch reads and writes. Remove the old structure only in a later, separately approved change after all consumers have moved. This is a pattern, not a guarantee: even an additive operation may require a disruptive lock on a particular engine.
| Stage | Operational question | Evidence to retain |
|---|---|---|
| Expand | Can the old release still operate? | Schema and compatibility test |
| Transition | Can concurrent writes and backfill coexist? | Progress, errors and reconciliation |
| Switch | Are all readers and writers using the new representation? | Application and worker checks |
| Contract | Is the old structure unused and recoverable? | Approval and restore decision |
Backfill design matters as much as the schema. Use stable keys, record a checkpoint, make reprocessing safe, and decide how changes made while the backfill runs are reconciled. Avoid a giant transaction that holds locks and generates unpredictable log or replica pressure. A dual-write transition needs an explicit source of truth and a procedure for detecting mismatches; it does not automatically make inconsistent writes safe. Test an interrupted backfill and a retry before production.
Coordinate releases, workers and one migration owner
Choose a single deployment step responsible for applying migrations to the intended database. In a multi-server deployment, Laravel's --isolated option acquires an atomic cache lock, provided every server uses the same supported central cache. Importantly, an attempt that does not obtain the lock can still exit successfully. Therefore, an exit code from each server is not proof that the migration completed: make the rollout wait for the designated migration job and inspect migration status and the actual schema. Do not assume a local file or in-memory cache coordinates separate machines.
The production confirmation bypass --force is appropriate only in an approved, non-interactive deployment after target verification; it does not make a destructive change safe. The migration command can change or delete data, so treat its execution as a privileged operation. Never use migrate:fresh or migrate:refresh against a production database as a routine deploy step: the former drops tables and the latter rolls migrations back and runs them again.
Long-running queue workers can still run older code after web traffic moves to the new release. Laravel's queue documentation describes restarting workers during deployment and using a process monitor to bring them back. Plan the restart or drain with the queue owner, consider in-flight jobs and retries, and verify that scheduler and workers run compatible code before a destructive contract step. Jobs created by the older release may still be waiting when new workers start.
Support windows and change planning
Database version is part of the migration plan. The following published PostgreSQL dates are support endpoints, not deadlines for a specific Laravel schema change or a prediction of migration risk. The PostgreSQL versioning policy lists supported releases and explains that major upgrades need a separate upgrade method. Confirm your managed provider's support terms independently.
PostgreSQL supported major versions: final release dates
Published support endpoints for majors supported on 29 November 2026
- PostgreSQL 1511 Nov 2027
- PostgreSQL 169 Nov 2028
- PostgreSQL 178 Nov 2029
- PostgreSQL 1814 Nov 2030
- PostgreSQL 1919 Nov 2031
View chart data
| Item | year | Note |
|---|---|---|
| PostgreSQL 15 | 11 Nov 2027 | |
| PostgreSQL 16 | 9 Nov 2028 | |
| PostgreSQL 17 | 8 Nov 2029 | |
| PostgreSQL 18 | 14 Nov 2030 | |
| PostgreSQL 19 | 19 Nov 2031 |
Include the database major, minor release and extension versions in the change record. Schedule a database major upgrade as its own tested project; do not combine it casually with a high-risk application migration. The chart uses calendar years to make the sequence legible, while its labels give the actual published final dates. Check the policy again when planning because schedules and support status change.
Verify the outcome and know when to stop
After migration, inspect both Laravel's status and the database objects actually created. Verify index and constraint validity with engine-specific, read-only inspection. Exercise a safe, authorised test record through the real application path: create, read and update it, then confirm the expected downstream job or event. Use a dedicated test account and a documented cleanup procedure; do not generate real customer payments or notifications as a smoke test.
Compare error rates, latency, lock waits, replication lag and queue age with the pre-change baseline. Assign someone to watch throughout the transition, not just until the deployment interface turns green. If the schema or a critical write is wrong, stop additional rollout and destructive cleanup. Determine whether the compatible previous code can safely run against the new schema; rolling code back is different from undoing a database change.
Laravel's rollback operates on migration batches and can execute destructive down methods. Inspect the exact batch and data consequences before using it. If restoring a backup is necessary, pause or isolate writes, communicate the recovery point and reconcile later transactions with the business owner. Save a short incident record and the evidence needed for the next rehearsal.
Sora Panel is not released yet. Read how it works on the homepage, and see the change-planning guide for a related maintenance workflow.
Frequently asked questions
Does a successful migrate command prove the release is safe?
No. Check the actual schema, application writes, workers, errors and migration status as well.
Can I run migrations from every deployment server?
Designate one migration owner. Laravel's isolated option needs a shared supported cache and a skipped attempt can still report success.
Does reverting the code undo a schema change?
No. Keep versions compatible and plan database recovery separately, including writes made after the recovery point.
Are additive migrations always nonblocking?
No. Locking and execution depend on the database engine, version and exact operation.
Sources
- Laravel migrations (viewed 2026-11-29)
- PostgreSQL explicit locking (viewed 2026-11-29)
- PostgreSQL SQL dump and restore (viewed 2026-11-29)
- Laravel queues (viewed 2026-11-29)
- PostgreSQL versioning policy (viewed 2026-11-29)
Sora Panel is not released yet. Read how it works on the homepage.