MigrAlign — align live MySQL tables with Laravel migration schema, safely.
migralign/laravel-migralign is a Laravel package for migralign — align live mysql tables with laravel migration schema, safely..
It currently has 0 GitHub stars and 9 downloads on Packagist (latest version v1.0.1).
Install it with composer require migralign/laravel-migralign.
Discover more Laravel packages by migralign
or browse all Laravel packages to compare alternatives.
Last updated
Align your database with your migrations.
Detect schema drift, add missing columns, auto-apply safe updates, and get guided confirmation for risky changes.
composer require migralign/laravel-migralign
Repository · Issues · Security
MigrAlign compares your Laravel migration-defined schema with the current MySQL/MariaDB schema and helps you synchronize differences safely.
It is useful when:
Schema::create() and Schema::table()information_schemaapplied, skipped, pending manual, errors)Install the package:
composer require migralign/laravel-migralign
Laravel auto-discovers the service provider; no manual registration is required.
Publish config (optional):
php artisan vendor:publish --tag=migralign-config
This creates:
config/migralign.phpphp artisan migralign:sync --dry-run
php artisan migralign:sync
config('migralign.migrations_path')up() logicinformation_schemaMigrAlign classifies each change into one of:
saferiskydestructiveVARCHAR(255) -> VARCHAR(50))For risky/destructive changes, MigrAlign shows:
php artisan migralign:sync
--dry-run
Show planned changes only, do not apply. Always exits with status 0, even when differences are found.
--force
Apply risky/destructive changes without interactive prompts. Also skips pre-check blocking when existing rows would violate the new schema. Use only when you explicitly accept that data risk.
--table=users
Limit sync to a specific table.
--migration=create_users
Scan only migrations with matching filename text.
--connection=mysql
Override DB connection used for introspection/apply.
# Preview everything
php artisan migralign:sync --dry-run
# Sync only users table
php artisan migralign:sync --table=users
# Preview a subset of migrations
php artisan migralign:sync --dry-run --migration=2024_01_01
# Apply all including risky (no prompts; bypasses pre-check blocking)
php artisan migralign:sync --force
Default config file:
return [
'migrations_path' => database_path('migrations'),
'ignored_tables' => [
'migrations',
'password_reset_tokens',
'sessions',
'cache',
'cache_locks',
'jobs',
'job_batches',
'failed_jobs',
],
'auto_apply_safe' => true,
'connection' => null,
];
migrations_path
Path to migration files used to build expected schema.
ignored_tables
Tables excluded from diffing.
auto_apply_safe
If true, safe changes apply automatically.
connection
Default DB connection. null means Laravel default.
When you add a column in migrations (Schema::create() or Schema::table()):
php artisan migralign:sync --dry-run
php artisan migralign:sync
If the column is nullable or otherwise safe, it is created automatically.
For changes like nullable(true) -> nullable(false) or length shrink:
--dry-runUse dry-run locally or in pipelines to review planned changes:
php artisan migralign:sync --dry-run
--dry-run always exits successfully (status 0), even when drift is detected. For CI gates that must fail on drift, parse the command output or add your own wrapper check.
Migration:
Schema::table('users', function (Blueprint $table) {
$table->string('phone', 20)->nullable();
});
Result:
add_column for users.phoneIf a column exists in DB but not in migration intent:
drop_columnMigration intent changes nullable column to not nullable:
modify_columnup() logic in recording mode; extremely dynamic migration logic may need extra careYour selected connection is not MySQL/MariaDB.
Use --connection= with a MySQL connection, or set migralign.connection.
migralign.migrations_path--migration= filter is not excluding itignored_tables--dry-run first--force only if you explicitly accept bypassing prompts and pre-check blockingPrefer adding new migrations for forward changes.
Editing old migrations can create large drift expectations across environments.
php artisan migrate?No. migrate applies migration history; MigrAlign aligns current schema intent to live schema through diff + risk controls.
Yes, but always run dry-run first and review destructive/risky operations.
Contributions are welcome. See CONTRIBUTING.md for setup, test commands, and pull request guidelines.
Report security issues privately — see SECURITY.md.
MIT