Download the PHP package sirval/laravel-smart-migrations without Composer
On this page you can find all versions of the php package sirval/laravel-smart-migrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sirval/laravel-smart-migrations
More information about sirval/laravel-smart-migrations
Files in sirval/laravel-smart-migrations
Package laravel-smart-migrations
Short Description Intelligently manage Laravel migrations with safe rollback by table or model, foreign key detection, preview mode, and comprehensive migration analysis tools
License MIT
Homepage https://github.com/sirval/laravel-smart-migrations
Informations about the package laravel-smart-migrations
Laravel Smart Migrations
Intelligently manage Laravel migrations with safe rollback, analysis, validation, and comprehensive tools for table and model-based operations.
A comprehensive Laravel package for intelligent migration management. Roll back migrations by table name or model, with explicit, safe options to prevent accidental data loss. Future versions will include analysis, validation, and optimization tools.
⭐ Give us a Star
If you find this package helpful, please consider giving us a star on GitHub! It helps us continue maintaining and improving this package. Your support means a lot to us! ☕
Installation
You can install the package via composer:
You can publish and run the migrations with:
You can publish the config file with:
This is the contents of the published config file:
Optionally, you can publish the views using
Usage
Available Commands
1. Rollback by Table Name
Roll back all migrations for a specific table:
2. Rollback by Model Name
Roll back all migrations associated with a specific model:
3. Rollback by Batch Number
Roll back all migrations from a specific batch:
4. List Migrations for Table
View all migrations affecting a specific table:
5. List Migrations for Model
View all migrations associated with a specific model:
Command Options
| Option | Short | Description | Default |
|---|---|---|---|
--latest |
-L |
Only rollback the latest migration | false |
--oldest |
-O |
Only rollback the oldest migration | false |
--all |
-A |
Rollback all migrations (ignore batch restrictions) | false |
--batch=N |
-B |
Only rollback migrations from batch N | null |
--force |
-F |
Skip confirmation prompts | false |
--interactive |
-I |
Show options and let user choose | false |
--preview |
— | Preview changes without executing rollback | false |
--check-fk |
— | Check and display foreign key constraints | false |
Advanced Features
Preview Mode (--preview)
Preview what migrations will be rolled back without making any database changes. This is useful for testing and validation before executing the actual rollback.
When you run with --preview, the command will:
- Show all migrations that would be rolled back
- Display any foreign key constraints (if
--check-fkis used) - Return successfully without making any changes to the database
Foreign Key Detection (--check-fk)
Automatically detect and display all foreign key constraints before rolling back migrations. This helps prevent breaking references between tables.
The foreign key check displays:
- Foreign Keys Defined in the Table: Keys that reference other tables
- Dependent Foreign Keys: Other tables that reference this table
Supported Databases:
- MySQL: Uses
INFORMATION_SCHEMAqueries - PostgreSQL: Uses
information_schemaviews - SQLite: Uses
PRAGMA foreign_key_list()
Combined Usage
For maximum safety, combine preview mode with foreign key detection:
This allows you to:
- See all migrations that will be rolled back
- Identify any foreign key constraints
- Verify safety without making changes
- Execute with confidence when ready
Configuration
The package respects these configuration options from config/smart-migrations.php:
Programmatic Usage
Use the SmartMigrations facade for programmatic access:
Available Options for Rollback Methods
When calling rollback methods programmatically, pass options as an array:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Ohuka Ikenna
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-smart-migrations with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0||^12.0