Download the PHP package grazulex/laravel-strongmigrations without Composer

On this page you can find all versions of the php package grazulex/laravel-strongmigrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-strongmigrations

Laravel Strong Migrations

[!TIP] What Laravel Strong Migrations does for you โ€” Catch the migration that would lock your users table for ten minutes before it reaches production. Static analysis of your migrations with database-specific rules, in block or warn mode, ready for CI.

This package is free and maintained on my own time. If it saves you hours, a small contribution helps me keep it going: ๐Ÿ’– GitHub Sponsors ยท โ˜• Buy Me a Coffee ยท PayPal

Tests Code Quality Latest Version on Packagist PHP Version License

Detect dangerous migrations before they hit production. Inspired by the Rails 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

Installation

Publish the configuration:

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:

Rules

Common Rules (All Databases)

Rule ID Detects Severity
remove_column Dropping a column High
rename_column Renaming a column High
rename_table Renaming a table High
create_table_force dropIfExists before create High
backfill_in_migration Data + schema changes in same migration Medium
add_auto_increment Adding auto-increment columns Medium
raw_sql Raw SQL statements Warning
wide_index Index with > 3 columns Low

MySQL / MariaDB Rules

Rule ID Detects Severity
add_column_with_default Adding NOT NULL column with default (< 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 constraint Medium

PostgreSQL Rules

Rule ID Detects Severity
add_index_non_concurrent Adding index without CONCURRENTLY High
add_foreign_key Adding foreign key (locks both tables) High
add_check_constraint Adding check constraint Medium
add_unique_constraint Adding unique constraint Medium
json_column Using json instead of jsonb Low
set_not_null_pgsql Setting NOT NULL (full table scan) Medium
add_column_volatile_default Adding a column with a volatile default (table rewrite) High

add_index_non_concurrent, add_unique_constraint, add_foreign_key and add_column_volatile_default only report changes to existing tables. Indexes, unique constraints and foreign keys declared inside Schema::create() (including Schema::connection(...)->create()) are not reported: the table is new and empty, so CONCURRENTLY or NOT VALID brings nothing there.

Volatile Defaults on PostgreSQL

Since PostgreSQL 11, adding a column with a constant or stable default ('active', 0, now(), CURRENT_TIMESTAMP, ->useCurrent()) only updates the catalog and is instant. A volatile default must be computed for every existing row, so PostgreSQL rewrites the whole table under an ACCESS EXCLUSIVE lock, whatever the version and whether the column is nullable or not. add_column_volatile_default reports these columns:

The rule inspects raw defaults written with DB::raw('...') or new Expression('...') and recognizes these volatile functions: gen_random_uuid(), uuidv4(), uuidv7(), uuid_generate_v1(), uuid_generate_v1mc(), uuid_generate_v4(), uuid_generate_v7(), gen_random_bytes(), random(), random_normal(), clock_timestamp(), timeofday() and nextval(). Plain string defaults are quoted by Laravel and never evaluated as SQL, so they are not reported. Columns declared inside Schema::create() are not reported either: the table is new and empty. On PostgreSQL versions older than 11 (not supported by this package), any default rewrites the table.

The detected expression is available to custom checks: AddColumn operations carry default_expression and volatile_default in their details.

Foreign Keys and Index Removals

Foreign keys are detected both with $table->foreign('user_id')->references('id')->on('users') and with the foreignId() shorthand. foreignId(), foreignIdFor(), foreignUuid() and foreignUlid() create a foreign key (an add_foreign_key operation) when chained with ->constrained() or ->references()->on(). A plain $table->foreignId('user_id') with neither only adds a column, so it is not reported as a foreign key.

The analyzer also emits removal operations that custom checks can consume (see Custom Checks):

Blueprint method Operation type(s)
dropForeign(), dropForeignIdFor() OperationType::RemoveForeignKey
dropConstrainedForeignId(), dropConstrainedForeignIdFor() OperationType::RemoveForeignKey + OperationType::RemoveColumn
dropIndex(), dropUnique(), dropPrimary(), dropFullText(), dropSpatialIndex() OperationType::RemoveIndex

RemoveIndex operations carry index_type (index, unique, primary, fulltext or spatial), index_name and columns in their details; RemoveForeignKey operations carry foreign_key_name and columns. When a column list is given (for example dropForeign(['user_id'])), the first column is also set as the operation column. Because dropConstrainedForeignId() drops the column too, it is reported by the remove_column rule.

Usage

Automatic Protection

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

Artisan Commands

Check all migrations

migrate:check honours the start_after baseline: migration files whose timestamp is lower than or equal to start_after are skipped, exactly like the migration listener does.

Analyze a specific migration

Bypassing Checks

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

Custom Checks

Add custom rules in a service provider:

Custom Messages

Override the default message for the next violation:

Configuration

Timeouts

When a migration starts, the configured timeouts are set on the migration's connection, so a migration waiting on a busy table fails fast instead of queueing every other query behind it. When the migration ends, the previous session values are restored.

Driver Settings Query
PostgreSQL statement_timeout, lock_timeout set_config(...) (same as SET)
MySQL / MariaDB lock_wait_timeout SET SESSION lock_wait_timeout = ...
SQLite / others โ€” nothing is executed

PostgreSQL values accept an integer (milliseconds) or a string with a unit ('10s', '1h'). The MySQL value is a whole number of seconds. Set any key to null to leave that setting untouched. Timeouts are applied regardless of safetyAssured and start_after, and are not applied when the package is disabled (enabled => false).

CI/CD Integration

GitHub Actions

This outputs annotations that appear directly on pull request diffs.

Generic CI

Returns exit code 1 if any violations are found.

Supported Databases

Database Version Notes
MySQL 5.7+ Version-aware rules (8.0.12+ allows instant ADD COLUMN)
MariaDB 10.2+ Version-aware rules (10.3.2+ allows instant ADD COLUMN)
PostgreSQL 12+ CONCURRENTLY, foreign key, constraint and volatile default rules
SQLite Any Reduced rule set (safe for development)

Requirements

Testing

Code Quality

Contributing

Please see CONTRIBUTING.md for details.

Security

If you discover a security vulnerability, please see SECURITY.md.

Support This Package

Laravel Strong Migrations is free, open source and maintained on my own time. If it saves you hours, here is how you can give back:

License

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


All versions of laravel-strongmigrations with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/support Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
nikic/php-parser Version ^5.9
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package grazulex/laravel-strongmigrations contains the following files

Loading the files please wait ...