Polyscope——面向 Laravel 的以代理为先的开发环境

Laravel Schema Sentinel: Detect and Fix Database Schema Drift

最后更新于 经过

Laravel Schema Sentinel: Detect and Fix Database Schema Drift image

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 migrate if 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

保罗·雷德蒙德照片

Laravel News 特约撰稿人。全栈 Web 开发人员兼作家。

归档于:
立方体

Laravel 时事通讯

加入超过 4 万名开发者的行列,不错过任何新的技巧、教程等内容。

图像
了解软科技

以每小时 20 美元的价格聘请具备人工智能专业知识的 Laravel 开发人员。48 小时内即可开始工作。

访问 Acquaint Softtech
Shift 标志

转移

还在运行旧版本的 Laravel?立即实现 Laravel 自动升级和代码现代化,让您的应用程序保持最新状态。

转移
Lucky Media 标志

幸运传媒

Get Lucky Now——拥有十余年经验的 Laravel 开发理想之选!

幸运传媒
Kirschbaum 标志

樱桃树

提供创新和稳定性,确保您的Web应用程序取得成功。

樱桃树
SerpApi logo

SerpApi

Access real-time search engine results through a simple API—no more scraping headaches! Use it for AI applications, SEO tools, product research, travel information, and more

SerpApi
了解 Softtech 的标志

了解软科技

Acquaint Softtech 提供 AI 就绪的 Laravel 开发人员,48 小时内即可上手,每月费用为 3000 美元,没有冗长的销售流程,并提供 100% 退款保证。

了解软科技
几天内即可获得 Laravel 代码审查徽标的专家指导

几天内即可获得 Laravel 代码审查方面的专家指导

专家级代码审查!两位拥有 10 年以上 Laravel 开发经验的开发者将为您提供清晰、实用的反馈,帮助团队构建更优质的应用程序。

几天内即可获得 Laravel 代码审查方面的专家指导
Laravel Cloud 标志

Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

Laravel 云
PhpStorm 标志

PhpStorm

首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

PhpStorm
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

SaaSykit 是一个多租户 Laravel SaaS 入门套件,包含运行现代 SaaS 所需的所有功能,例如支付、美观的结账界面、管理面板、用户仪表盘、身份验证、现成组件、统计数据、博客、文档等等。

SaaSykit:Laravel SaaS 入门套件
鱼叉:新一代时间跟踪和发票标志

Harpoon:新一代时间跟踪和发票系统

新一代时间跟踪和计费软件,帮助您的机构规划和预测盈利的未来。

Harpoon:新一代时间跟踪和发票系统
Tinkerwell 徽标

廷克威尔

Laravel 开发者必备的代码运行器。可在本地和生产环境中体验 AI、自动补全和即时反馈功能。

廷克威尔
Laravel Brain: Visualize Your Application's Request Lifecycle image

Laravel Brain: Visualize Your Application's Request Lifecycle

阅读文章
Laravel Shopper: A Headless E-Commerce Admin Panel for Laravel image

Laravel Shopper: A Headless E-Commerce Admin Panel for Laravel

阅读文章
Chevere Workflow: A Declarative PHP Workflow Engine with Async Job Execution image

Chevere Workflow: A Declarative PHP Workflow Engine with Async Job Execution

阅读文章
Laravel Web Push Notifications image

Laravel Web Push Notifications

阅读文章
RedBerry to Host Georgia's First Laravel Meetup in Tbilisi image

RedBerry to Host Georgia's First Laravel Meetup in Tbilisi

阅读文章
Interruptible Jobs in Laravel 13.7.0 image

Interruptible Jobs in Laravel 13.7.0

阅读文章