Search by

swisnl / laravel-database-guard

swisnl

Database guard for Laravel

Package info

github.com/swisnl/laravel-database-guard

pkg:composer/swisnl/laravel-database-guard

Statistics

Installs: 20

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

dev-master 2026-10-14 06:44 UTC

This package is auto-updated.

Last update: 2026-10-14 12:58:14 UTC


README

Latest Version on Packagist Software License Tests

Introduction

A single Laravel migration can take down a production database. MySQL takes an exclusive metadata lock for every schema change, and most changes do more than flip metadata: adding an index, changing a column type or dropping a primary key rebuilds or scans the whole table. On a large table that can take minutes or hours, and while it runs:

  • On a single server, writes to the table block, and every query on it queues behind the DDL if a long-running transaction delays the lock.
  • With async replicas, the change replays on each replica afterwards, stopping replication for the same duration.
  • On HA clusters such as Percona XtraDB Cluster or Galera, schema changes run in lockstep on every node (TOI), so the whole cluster stops committing writes until the change completes.

These migrations look harmless in review and pass every test, because development and CI databases are small. The problem only shows on production data volumes, during a deployment.

This package stops those migrations before they run.

Install

composer require swisnl/laravel-database-guard

Optionally publish the config file:

php artisan vendor:publish --tag=database-guard

Usage

TODO

Testing

composer test
composer analyse
composer lint

Changelog

See CHANGELOG for recent changes.

Contributing

See CONTRIBUTING for details.

Security

If you discover any security related issues, please email security@swis.nl instead of using the issue tracker.

License

The MIT License (MIT). See License File for more information.