Laravel Schema Sentinel by Ahtesham at Broadway Web Service detects schema drift— to help identify when your actual database no longer matches your migrations. It builds a shadow database from your migrations, diffs it against the live schema, and can generate a corrective migration when the two diverge.
- Deep drift detection — audits tables, columns, data types, nullability, defaults, indexes, and foreign keys
- Cross-environment comparison — verify local migrations match staging or production
- Auto-generated migrations — create corrective migrations with interactive review
- Visual dashboard — built-in Livewire component for database health monitoring
- Pre-migration guard
— automatically block
php artisan migrateif drift is detected - 和更多...
Detecting Drift
The core command runs your migrations into a temporary shadow database, then compares that shadow against your live connection:
php
工匠
schema:drift
It checks tables, columns, data types, nullability, defaults, indexes, and foreign keys. Running with
--strict
also flags columns or tables present in the live database that have no corresponding migration.
Generating a Fix
When drift is found, you can have Sentinel generate a migration to close the gap:
php
工匠
schema:drift
--fix
--interactive
Interactive mode walks you through each detected difference before writing anything. A
--sql
flag skips file creation and prints the migration code to the terminal for review.
Cross-Environment Comparison
You can point the diff at a different environment's database connection instead of your local one:
php
工匠
schema:drift
--compare-env=staging
This uses the named connection from your
config/database.php
, so you can verify your local migrations match what's deployed to staging or production before running them.
Programmatic API
A
Sentinel
facade exposes the same diff as a DTO, which you can use in controllers, Livewire components, or admin dashboards:
使用
Sentinel\SchemaSentinel\Facades\Sentinel
;差异
=
Sentinel
::
查看
(
严格的
:
真的
(英文):返回
回复
()
->
json
([
'in_sync'
=>
!
差异
->
hasDifferences
(),
'drift'
=>
差异
->
数组
(),]);
The package also ships a Blade-embeddable Livewire component for a visual health dashboard, though it only renders in local environments:
<
livewire:sentinel-database-health
/>
The package supports Laravel 11.x through 13.x. You can find Laravel Schema Sentinel on GitHub 。







