Download the PHP package whilesmart/eloquent-schema-conformance without Composer
On this page you can find all versions of the php package whilesmart/eloquent-schema-conformance. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download whilesmart/eloquent-schema-conformance
More information about whilesmart/eloquent-schema-conformance
Files in whilesmart/eloquent-schema-conformance
Package eloquent-schema-conformance
Short Description Declarative database schema-conformance guard for Laravel: declare the columns and indexes each feature expects, verify the live DB against them, additively conform, and refuse to serve on drift.
License MIT
Informations about the package eloquent-schema-conformance
eloquent-schema-conformance
A declarative database schema-conformance guard for Laravel. Declare the columns and indexes each feature expects, verify the live database against them, additively conform, and optionally refuse to serve while the schema drifts.
It exists to catch a specific class of bug: a migration that alters an existing table can reach one environment and not another, leaving a table that looks intact but rejects writes. Instead of editing old migrations defensively, you declare the expected end state once; the guard turns "an ALTER never ran here" into a clear 503 (or a failing test) rather than a runtime write error.
Install
Declare the spec
In config/schema.php, each feature declares the table state it expects after its migrations run:
Column specs use Blueprint types (string, integer, json, enum with values, …) with nullable, default, length, unique modifiers. Index specs are ['columns' => [...], 'name' => 'optional', 'unique' => bool].
Commands
| Command | Purpose |
|---|---|
schema:verify |
Read-only. Reports every missing table, column, or index. |
schema:conform |
Adds missing columns and indexes in place. Never drops or alters. --dry-run to preview. |
schema:conform also runs automatically after every migrate/migrate:fresh (disable with SCHEMA_CONFORMANCE_AUTO_CONFORM=false).
Enforce at the edge
Attach the middleware (aliased schema.conformance) to a route group. While the live schema drifts from the spec, requests get a 503 listing the problems; the result is cached for schema.cache_ttl seconds. Disable with SCHEMA_CONFORMANCE_ENFORCE=false in local dev. Paths in schema.bypass_paths are never gated.