PHPackages                             grazulex/laravel-strongmigrations - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. grazulex/laravel-strongmigrations

ActiveLibrary[Testing &amp; Quality](/categories/testing)

grazulex/laravel-strongmigrations
=================================

Detect dangerous migrations before they break production. Catch unsafe operations, get guided alternatives, and keep your database safe.

v1.0.0(2mo ago)10MITPHPPHP ^8.2CI passing

Since Feb 25Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Grazulex/laravel-strongmigrations)[ Packagist](https://packagist.org/packages/grazulex/laravel-strongmigrations)[ Docs](https://github.com/grazulex/laravel-strongmigrations)[ Fund](https://www.buymeacoffee.com/Grazulex)[ Fund](https://paypal.me/strauven)[ RSS](/packages/grazulex-laravel-strongmigrations/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

Laravel Strong Migrations
=========================

[](#laravel-strong-migrations)

[![Tests](https://github.com/grazulex/laravel-strongmigrations/actions/workflows/tests.yml/badge.svg)](https://github.com/grazulex/laravel-strongmigrations/actions/workflows/tests.yml)[![Code Quality](https://github.com/grazulex/laravel-strongmigrations/actions/workflows/code-quality.yml/badge.svg)](https://github.com/grazulex/laravel-strongmigrations/actions/workflows/code-quality.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/075937b70455776259f56384fe2a829fa279e7dd0aad82e6f28c7e55cd5d5c12/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6772617a756c65782f6c61726176656c2d7374726f6e676d6967726174696f6e732e737667)](https://packagist.org/packages/grazulex/laravel-strongmigrations)[![PHP Version](https://camo.githubusercontent.com/88e26956da40e084aed2212a08da8400c4799b307a06dd1e6084cfc59eda4097/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6772617a756c65782f6c61726176656c2d7374726f6e676d6967726174696f6e732e737667)](https://packagist.org/packages/grazulex/laravel-strongmigrations)[![License](https://camo.githubusercontent.com/80372f10fd4e8704421a9663e9d36a89612431fa4815eabdcbce7c46b2508578/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6772617a756c65782f6c61726176656c2d7374726f6e676d6967726174696f6e732e737667)](https://packagist.org/packages/grazulex/laravel-strongmigrations)

Detect dangerous migrations before they hit production. Inspired by the Rails [strong\_migrations](https://github.com/ankane/strong_migrations) gem.

Laravel Strong Migrations analyzes your migration files using AST parsing (nikic/php-parser) and warns you about operations that could cause downtime, data loss, or lock contention on large tables.

Features
--------

[](#features)

- **16+ built-in rules** covering common dangerous operations
- **Database-aware** — version-specific rules for MySQL, MariaDB, and PostgreSQL
- **Two modes** — `block` (prevents migration) or `warn` (displays warning)
- **AST-based analysis** — no migration execution required
- **CI/CD ready** — JSON and GitHub Actions output formats
- **Customizable** — disable rules, add custom checks, bypass with `safetyAssured`
- **Multilingual** — English and French translations included

Installation
------------

[](#installation)

```
composer require grazulex/laravel-strongmigrations
```

Publish the configuration:

```
php artisan strong-migrations:install
```

How It Works
------------

[](#how-it-works)

Strong Migrations listens to Laravel's `MigrationStarted` event. When you run `php artisan migrate`, each migration is parsed and checked against the rule engine **before** it executes.

If a dangerous operation is detected:

- In **block** mode (default): an exception is thrown with a safe alternative
- In **warn** mode: a warning is displayed, migration proceeds

Rules
-----

[](#rules)

### Common Rules (All Databases)

[](#common-rules-all-databases)

Rule IDDetectsSeverity`remove_column`Dropping a columnHigh`rename_column`Renaming a columnHigh`rename_table`Renaming a tableHigh`create_table_force``dropIfExists` before `create`High`backfill_in_migration`Data + schema changes in same migrationMedium`add_auto_increment`Adding auto-increment columnsMedium`raw_sql`Raw SQL statementsWarning`wide_index`Index with &gt; 3 columnsLow### MySQL / MariaDB Rules

[](#mysql--mariadb-rules)

Rule IDDetectsSeverity`add_column_with_default`Adding NOT NULL column with default (&lt; MySQL 8.0.12 / MariaDB 10.3.2)High`change_column_type`Changing column type (table rewrite)High`set_not_null_mysql`Setting NOT NULL constraintMedium### PostgreSQL Rules

[](#postgresql-rules)

Rule IDDetectsSeverity`add_index_non_concurrent`Adding index without CONCURRENTLYHigh`add_foreign_key`Adding foreign key (locks both tables)High`add_check_constraint`Adding check constraintMedium`add_unique_constraint`Adding unique constraintMedium`json_column`Using `json` instead of `jsonb`Low`set_not_null_pgsql`Setting NOT NULL (full table scan)MediumUsage
-----

[](#usage)

### Automatic Protection

[](#automatic-protection)

Once installed, Strong Migrations automatically checks all migrations during `php artisan migrate`:

```
$ php artisan migrate

Dangerous operation detected in migration: 2025_01_15_000001_drop_email.php

[remove_column] Removing column `email` that is used by the application
will cause errors until application servers are restarted.

Safe alternative:

Step 1 - Ignore the column in your Eloquent model:
    protected static array $ignoredColumns = ['email'];

Step 2 - Deploy the code.

Step 3 - Create a migration that drops the column, wrapped in:
    StrongMigrations::safetyAssured(function () { ... });

```

### Artisan Commands

[](#artisan-commands)

#### Check all migrations

[](#check-all-migrations)

```
# Text output (default)
php artisan migrate:check

# JSON output (for CI/CD)
php artisan migrate:check --format=json

# GitHub Actions annotations
php artisan migrate:check --format=github

# Custom path
php artisan migrate:check --path=database/migrations
```

#### Analyze a specific migration

[](#analyze-a-specific-migration)

```
php artisan migrate:analyze 2025_01_15_000001_drop_email.php
```

### Bypassing Checks

[](#bypassing-checks)

When you've verified a migration is safe, wrap it in `safetyAssured`:

```
use Grazulex\StrongMigrations\StrongMigrations;

return new class extends Migration
{
    public function up(): void
    {
        StrongMigrations::safetyAssured(function () {
            Schema::table('users', function (Blueprint $table) {
                $table->dropColumn('legacy_field');
            });
        });
    }
};
```

### Custom Checks

[](#custom-checks)

Add custom rules in a service provider:

```
use Grazulex\StrongMigrations\StrongMigrations;

StrongMigrations::addCheck(function (Operation $operation, DatabaseContext $context) {
    if ($operation->type === OperationType::AddColumn && $operation->column === 'metadata') {
        StrongMigrations::stop('Use `data` instead of `metadata` for consistency.');
    }
});
```

### Custom Messages

[](#custom-messages)

Override the default message for the next violation:

```
StrongMigrations::setMessage('This migration has been reviewed and approved by the DBA team.');
```

Configuration
-------------

[](#configuration)

```
// config/strong-migrations.php
return [
    // Enable/disable the package
    'enabled' => env('STRONG_MIGRATIONS_ENABLED', true),

    // 'block' or 'warn'
    'mode' => env('STRONG_MIGRATIONS_MODE', 'block'),

    // Override auto-detected database driver
    'database_driver' => env('STRONG_MIGRATIONS_DRIVER'),

    // Override auto-detected database version
    'database_version' => env('STRONG_MIGRATIONS_VERSION'),

    // Skip migrations before this timestamp (format: YYYY_MM_DD_HHMMSS)
    'start_after' => null,

    // Disable specific rules by ID
    'disabled_checks' => [
        // 'remove_column',
        // 'raw_sql',
    ],
];
```

CI/CD Integration
-----------------

[](#cicd-integration)

### GitHub Actions

[](#github-actions)

```
- name: Check migrations
  run: php artisan migrate:check --format=github
```

This outputs annotations that appear directly on pull request diffs.

### Generic CI

[](#generic-ci)

```
- name: Check migrations
  run: php artisan migrate:check --format=json
```

Returns exit code 1 if any violations are found.

Supported Databases
-------------------

[](#supported-databases)

DatabaseVersionNotesMySQL5.7+Version-aware rules (8.0.12+ allows instant ADD COLUMN)MariaDB10.2+Version-aware rules (10.3.2+ allows instant ADD COLUMN)PostgreSQL12+CONCURRENTLY, foreign key, and constraint rulesSQLiteAnyReduced rule set (safe for development)Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11.x or 12.x

Testing
-------

[](#testing)

```
composer test
```

Code Quality
------------

[](#code-quality)

```
composer phpstan    # PHPStan level 8
composer pint       # Laravel Pint
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover a security vulnerability, please see [SECURITY.md](SECURITY.md).

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE.md](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance85

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

76d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/888105bd54b6b7f7905523a16a1d08eebc2e5d39b19a4c174b5961bb4d52929b?d=identicon)[Grazulex](/maintainers/Grazulex)

---

Top Contributors

[![Grazulex](https://avatars.githubusercontent.com/u/4521546?v=4)](https://github.com/Grazulex "Grazulex (4 commits)")

---

Tags

pestlaraveldatabasemigrationsphp8safetystrong-migrations

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/grazulex-laravel-strongmigrations/health.svg)

```
[![Health](https://phpackages.com/badges/grazulex-laravel-strongmigrations/health.svg)](https://phpackages.com/packages/grazulex-laravel-strongmigrations)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[code-distortion/adapt

A Laravel package that builds databases for your tests, improving their speed.

2835.5k](/packages/code-distortion-adapt)[grazulex/laravel-devtoolbox

Swiss-army artisan CLI for Laravel — Scan, inspect, debug, and explore every aspect of your Laravel application from the command line.

1535.4k](/packages/grazulex-laravel-devtoolbox)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3418.6k](/packages/dragon-code-laravel-data-dumper)[orptech/laravel-migration-partition

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

3426.7k](/packages/orptech-laravel-migration-partition)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
