PHPackages                             marwen-brini/smart-migration - 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. [Database &amp; ORM](/categories/database)
4. /
5. marwen-brini/smart-migration

ActiveLibrary[Database &amp; ORM](/categories/database)

marwen-brini/smart-migration
============================

Production-ready Laravel migrations with web dashboard, auto-diff, drift detection, automatic backups, and safe rollback. 909 tests with 100% coverage.

2.0.0(5mo ago)00MITPHPPHP ^8.3||^8.4CI passing

Since Oct 5Pushed 5mo agoCompare

[ Source](https://github.com/Marwen-Brini/smart-migration)[ Packagist](https://packagist.org/packages/marwen-brini/smart-migration)[ Docs](https://github.com/marwen-brini/smart-migration)[ GitHub Sponsors](https://github.com/Marwen-Brini)[ RSS](/packages/marwen-brini-smart-migration/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (7)Used By (0)

🛡️ Smart Migration Package for Laravel
======================================

[](#️-smart-migration-package-for-laravel)

[![Latest Version](https://camo.githubusercontent.com/8bf7cec810f7cd1749c2b4d768e7dd1ab9751563eef8a8daf1cf10d568927c9e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d76322e302e302d626c75653f7374796c653d666c61742d737175617265)](https://github.com/marwen-brini/smart-migration)[![PHP Version](https://camo.githubusercontent.com/dc42fef08882a66844cfa055241803a761e286d650b757bce6f4aaf1104fcc9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e33253230253743253230382e342d3737374242343f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://github.com/marwen-brini/smart-migration)[![Laravel](https://camo.githubusercontent.com/eda16e09d5014e719a30b65115d3092d39f3a0ccaef25755f4c7722558155de4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d313125323025374325323031322d4646324432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://github.com/marwen-brini/smart-migration)[![Tests](https://camo.githubusercontent.com/dfa226fbc0bff6ce649f8655f08153e7741f6e0e59125b2c3b20d2b2aaf29bcf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d39303925323070617373696e672d627269676874677265656e3f7374796c653d666c61742d737175617265)](https://github.com/marwen-brini/smart-migration)[![Coverage](https://camo.githubusercontent.com/50a4fbc8e51d67d8814fd8ab90d2cbd132da38b8d00c18c96634f969c20867a8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e3f7374796c653d666c61742d737175617265)](https://github.com/marwen-brini/smart-migration)[![License](https://camo.githubusercontent.com/c090e080484e2a2bc766446291d04437db823929042bf614b26a1643660ddf6f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e3f7374796c653d666c61742d737175617265)](LICENSE.md)

**Never fear migrations again!** Smart Migration provides safety, visibility, and confidence when running Laravel migrations. Preview changes before they happen, automatically backup data, and rollback without data loss.

> **🚀 Current Version**: v2.0.0 - Now with Web Dashboard! 🎉
>
> Beautiful Vue 3 dashboard for visual migration management, real-time monitoring, and interactive schema exploration. 909 tests with 100% code coverage.

✨ Features
----------

[](#-features)

### Core Safety Features

[](#core-safety-features)

- 🔍 **Preview migrations** - See exact SQL and impact before running
- 🛡️ **Automatic backups** - Never lose data during migrations
- ↩️ **Safe rollbacks** - Archive instead of dropping data
- ⚠️ **Risk assessment** - Know which operations are dangerous
- ⏱️ **Time estimation** - Understand how long migrations will take

### Advanced Features

[](#advanced-features)

- 🐘 **Multi-Database Support** - Full support for MySQL, PostgreSQL, and SQLite
- 🔎 **Drift Detection** - Detect schema differences between migrations and database
- 📸 **Schema Snapshots** - Version control for your database schema with format versioning
- 🧹 **Auto-cleanup** - Automatic cleanup of old archived data
- ⚙️ **Configuration System** - Comprehensive configuration options
- 🔄 **Database Abstraction** - Unified interface across different database engines
- ✨ **Auto-Diff** - Automatically generate migrations from database changes
- 🔖 **Snapshot Versioning** - Prevent false positives when upgrading package versions

### 🎨 Web Dashboard (NEW!)

[](#-web-dashboard-new)

- 📊 **Visual Migration Management** - Beautiful web interface for managing migrations
- 🔄 **Real-time Monitoring** - Auto-refreshing dashboard with live status updates
- 🗂️ **Interactive Schema Explorer** - Browse and search your database structure
- 📈 **Performance Metrics** - Charts and graphs for migration performance
- ⏱️ **Migration Timeline** - Visual history of all applied migrations
- ⚠️ **Drift Alerts** - Visual warnings when schema diverges from migrations
- 🎯 **Risk Indicators** - Color-coded risk levels for pending migrations

📦 Requirements
--------------

[](#-requirements)

- PHP 8.3 or 8.4
- Laravel 11.0 or 12.0 (fully tested on both versions)
- Database: MySQL 5.7+, PostgreSQL 10+, or SQLite 3.8+

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

[](#installation)

You can install the package via composer:

```
composer require marwen-brini/smart-migration --dev
```

> **Note**: v2.0.0 is a stable release with 100% test coverage (909 tests), fully tested and ready for production use.

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="smart-migration-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="smart-migration-config"
```

The config file includes comprehensive settings for:

- **Safety Features**: Auto-backup, safe rollback, confirmation requirements
- **Backup Settings**: Storage path, retention, compression options
- **Archive Configuration**: Retention periods, naming conventions
- **Snapshot Management**: Storage, format (json/yaml/php), rotation
- **Drift Detection**: Ignored tables/columns patterns
- **Risk Assessment**: Customizable operation classifications
- **Display Options**: Verbosity, emojis, progress bars
- **Database Drivers**: Driver-specific settings (MySQL, PostgreSQL, SQLite)
- **Notifications**: Slack, webhooks, email configuration
- **Performance**: Chunk sizes, timeout settings

View the [full configuration file](config/smart-migration.php) for all available options.

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Preview what will happen before running migrations

[](#1-preview-what-will-happen-before-running-migrations)

```
php artisan migrate:plan
```

Output:

```
🔍 Smart Migration Plan Analysis
─────────────────────────────────────────────────────────

Migration: 2025_01_15_000000_create_users_table
─────────────────────────────────────────────────────────
✅ SAFE    | Create table 'users'
           | SQL: CREATE TABLE users (...)
           | Impact: New table will be created
           | Duration: ~10ms

✅ SAFE    | Add column 'email' to 'users'
           | SQL: ALTER TABLE users ADD email VARCHAR(255)
           | Impact: 0 rows will get new column
           | Duration: ~10ms

Summary:
- 2 safe operations
- Estimated total time: ~20ms

```

### 2. Run migrations with automatic backups

[](#2-run-migrations-with-automatic-backups)

```
php artisan migrate:safe
```

Output:

```
🛡️ Smart Migration - Safe Mode
─────────────────────────────────────────────────────────

Migration Plan:
─────────────────────────────────────────────────────────
📄 2025_01_15_000000_create_users_table
   ✅ 2 safe
   ⏱️ Estimated time: ~20ms

Do you want to proceed with these migrations? (yes/no) [no]: yes

Processing: 2025_01_15_000000_create_users_table
Tables to backup: users
✅ Completed in 25ms

```

### 3. Safely rollback without losing data

[](#3-safely-rollback-without-losing-data)

```
php artisan migrate:undo
```

Output:

```
↩️ Smart Migration - Safe Undo
─────────────────────────────────────────────────────────
Data will be preserved by archiving tables/columns instead of dropping them.

Rollback Plan:
─────────────────────────────────────────────────────────
📄 2025_01_15_000000_create_users_table
   📦 Table 'users' will be archived (150 rows)

Do you want to proceed with this safe rollback? (yes/no) [no]: yes

Rolling back: 2025_01_15_000000_create_users_table
✅ Rolled back in 30ms

📦 Archived items (preserved with timestamp 20250115_143022):
  - Table: _archived_users_20250115_143022 (150 rows)

💡 Tip: Archived data will be kept for 7 days before automatic cleanup.
   You can restore it manually if needed using SQL commands.

```

🎨 Web Dashboard
---------------

[](#-web-dashboard)

Launch the visual dashboard for a complete migration management experience:

```
php artisan migrate:ui
```

The dashboard will be available at `http://localhost:8080`

### Dashboard Features

[](#dashboard-features)

**Migration Management**:

- ✅ Preview migrations before running with SQL and risk assessment
- ✅ Run migrations safely with visual progress tracking
- ✅ Safe rollback with data preservation confirmations
- ✅ Test migrations on temporary database
- ✅ Detect and resolve migration conflicts

**Schema Tools**:

- ✅ Interactive schema explorer with table/column browsing
- ✅ Drift detection with visual alerts
- ✅ Auto-diff generator to create migrations from changes
- ✅ Schema snapshots management

**Monitoring &amp; Analytics**:

- ✅ Real-time migration status dashboard
- ✅ Performance metrics and charts
- ✅ Migration history timeline
- ✅ Export functionality (HTML, CSV, JSON)

**User Experience**:

- ✅ Auto-refresh every 30 seconds
- ✅ Toast notifications for actions
- ✅ Color-coded risk indicators
- ✅ Responsive design with Tailwind CSS

### Dashboard Navigation

[](#dashboard-navigation)

- **Overview** - Dashboard summary and quick statistics
- **Migrations** - Manage and execute database migrations
- **Schema** - Explore your database structure
- **Schema Drift** - Detect and fix schema drift
- **Snapshots** - Manage schema snapshots
- **Metrics** - View migration performance metrics
- **History** - Migration execution timeline
- **Performance** - Performance monitoring and baselines
- **Conflicts** - Detect migration conflicts
- **Auto-Diff** - Generate migrations from database changes

### API Endpoints

[](#api-endpoints)

The dashboard is built on a comprehensive REST API:

```
GET  /api/smart-migration/status
GET  /api/smart-migration/migrations
GET  /api/smart-migration/migrations/preview/{migration}
POST /api/smart-migration/migrations/run-safe
POST /api/smart-migration/migrations/undo-safe
POST /api/smart-migration/migrations/test
GET  /api/smart-migration/migrations/conflicts
GET  /api/smart-migration/migrations/diff
POST /api/smart-migration/migrations/diff/generate
GET  /api/smart-migration/schema
GET  /api/smart-migration/drift
GET  /api/smart-migration/snapshots
POST /api/smart-migration/snapshots
DELETE /api/smart-migration/snapshots/{name}
GET  /api/smart-migration/metrics
GET  /api/smart-migration/history
GET  /api/smart-migration/performance/baselines
GET  /api/smart-migration/performance/report

```

📘 Commands Reference
--------------------

[](#-commands-reference)

### Core Commands

[](#core-commands)

#### `migrate:plan`

[](#migrateplan)

Preview exactly what a migration will do before running it.

```
# Preview all pending migrations
php artisan migrate:plan

# Preview a specific migration
php artisan migrate:plan 2025_01_15_000000_create_users_table
```

#### `migrate:safe`

[](#migratesafe)

Run migrations with automatic backups and rollback on failure.

```
# Run pending migrations safely
php artisan migrate:safe

# Force run in production
php artisan migrate:safe --force

# See SQL without executing
php artisan migrate:safe --pretend
```

#### `migrate:undo`

[](#migrateundo)

Rollback migrations without data loss by archiving instead of dropping.

```
# Rollback last migration
php artisan migrate:undo

# Rollback multiple migrations
php artisan migrate:undo --step=3

# Rollback specific batch
php artisan migrate:undo --batch=5
```

### Advanced Commands

[](#advanced-commands)

#### `migrate:diff`

[](#migratediff)

Automatically generate migrations from database changes (smart column rename detection included).

```
# Auto-generate migration from database changes
php artisan migrate:diff

# Preview differences without generating migration
php artisan migrate:diff --dry-run

# Generate without confirmation
php artisan migrate:diff --force

# Generate with custom name
php artisan migrate:diff --name=update_user_schema

# Check specific tables only
php artisan migrate:diff --tables=users,posts

# Ignore snapshot version warnings
php artisan migrate:diff --ignore-version-mismatch
```

#### `migrate:check`

[](#migratecheck)

Detect schema drift between your migrations and database.

```
# Check for schema drift
php artisan migrate:check

# Show detailed comparison
php artisan migrate:check --details

# Auto-generate fix migration
php artisan migrate:check --fix

# Ignore snapshot version warnings
php artisan migrate:check --ignore-version-mismatch
```

#### `migrate:snapshot`

[](#migratesnapshot)

Manage database schema snapshots for versioning.

```
# Create a snapshot
php artisan migrate:snapshot create [name]

# List all snapshots
php artisan migrate:snapshot list

# Show snapshot details
php artisan migrate:snapshot show

# Compare two snapshots
php artisan migrate:snapshot compare  --compare-with=

# Delete a snapshot
php artisan migrate:snapshot delete
```

#### `migrate:cleanup`

[](#migratecleanup)

Clean up old archived tables and columns.

```
# Clean up old archives
php artisan migrate:cleanup

# Preview cleanup without deleting
php artisan migrate:cleanup --dry-run

# Show archive statistics
php artisan migrate:cleanup --stats
```

#### `migrate:config`

[](#migrateconfig)

Display current Smart Migration configuration.

```
# Show all configuration
php artisan migrate:config

# Show specific section
php artisan migrate:config --section=safety
```

#### `migrate:ui`

[](#migrateui)

Launch the web dashboard for visual migration management.

```
# Start dashboard server
php artisan migrate:ui

# Custom port and host
php artisan migrate:ui --port=3000 --host=127.0.0.1
```

**Dashboard Features:**

- 📊 Real-time migration status overview
- 🔍 Interactive schema explorer
- 📈 Performance metrics and charts
- ⏱️ Migration history timeline
- ⚠️ Schema drift alerts
- 🎨 Beautiful, responsive UI

**First Time Setup:**

```
# Navigate to package directory
cd vendor/marwen-brini/smart-migration

# Install frontend dependencies
npm install

# Return to your project
cd ../../../
```

Then run `php artisan migrate:ui` to launch the dashboard at `http://localhost:8080`

See [DASHBOARD\_IMPLEMENTATION.md](DASHBOARD_IMPLEMENTATION.md) for complete documentation.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Marwen-Brini](https://github.com/Marwen-Brini)
- [All Contributors](../../contributors)

🗺️ Roadmap
----------

[](#️-roadmap)

### ✅ POC (v0.1.0) - Complete!

[](#-poc-v010---complete)

- `migrate:plan` - Preview migrations with SQL and impact
- `migrate:safe` - Run with automatic backups
- `migrate:undo` - Rollback without data loss
- Risk assessment (SAFE/WARNING/DANGER)
- Time estimation
- Full test coverage

### ✅ MVP (v0.3.0) - Complete!

[](#-mvp-v030---complete)

- `migrate:check` - Detect schema drift
- `migrate:snapshot` - Save schema state
- `migrate:config` - Display configuration
- `migrate:cleanup` - Clean archived data
- PostgreSQL support
- SQLite support
- Database abstraction layer
- Configuration file system
- Auto-cleanup with scheduled jobs
- Comprehensive test coverage
- Laravel 11 &amp; 12 compatibility

### ✅ Stable (v1.0.0)

[](#-stable-v100)

- `migrate:diff` - Auto-generate migrations from database changes
- Smart column rename detection (Levenshtein algorithm)
- Snapshot format versioning
- Comprehensive multi-database support (MySQL, PostgreSQL, SQLite)
- 100% test coverage (592 tests)
- Production-ready stability

### ✅ Dashboard (v2.0.0) - Current Release!

[](#-dashboard-v200---current-release)

- `migrate:ui` - Web dashboard command
- Real-time migration status overview
- Interactive schema explorer with search
- Performance metrics and charts
- Migration history timeline
- Schema drift alerts
- Vue 3 + Vite + Tailwind CSS
- RESTful API endpoints
- Auto-refresh functionality
- Responsive design
- 100% test coverage (909 tests)

### 🔮 Future (v2.1+)

[](#-future-v21)

- WebSocket real-time updates
- Team features and approvals
- CI/CD integrations
- Cloud backup integration
- Manual migration execution from dashboard
- Drag-and-drop migration ordering
- Export reports (PDF, CSV)
- Dark mode theme
- Advanced rollback strategies
- Migration performance profiling

See the full [Development Roadmap](smart-migration-roadmap.md) for detailed plans.

🤝 Contributing
--------------

[](#-contributing)

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

🐛 Issues &amp; Feedback
-----------------------

[](#-issues--feedback)

Found a bug or have a suggestion? Please [open an issue](https://github.com/marwen-brini/smart-migration/issues) on GitHub.

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance75

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity57

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

Every ~44 days

Total

2

Last Release

169d ago

Major Versions

1.0.0 → 2.0.02025-11-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/c081aa8f05c4eec0f617cd95ebe284deea7279f694c18b084f3edfa2af992176?d=identicon)[Marwen-Brini](/maintainers/Marwen-Brini)

---

Top Contributors

[![Marwen-Brini](https://avatars.githubusercontent.com/u/23398443?v=4)](https://github.com/Marwen-Brini "Marwen-Brini (51 commits)")

---

Tags

laraveldatabasebackupmysqlsqlitepostgresqlmigrationsdashboarddrift-detectionsafetyrollbackMarwen-Brinismart-migrationauto-diffschema-snapshots

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/marwen-brini-smart-migration/health.svg)

```
[![Health](https://phpackages.com/badges/marwen-brini-smart-migration/health.svg)](https://phpackages.com/packages/marwen-brini-smart-migration)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M186](/packages/spatie-laravel-backup)[vcian/laravel-db-auditor

Database DB Auditor provide leverage to audit your MySql,sqlite, PostgreSQL database standards and also provide options to add constraints in table.

28535.1k1](/packages/vcian-laravel-db-auditor)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[moharrum/laravel-adminer

Adminer database management tool for your Laravel application.

451.0k](/packages/moharrum-laravel-adminer)[orptech/laravel-migration-partition

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

3426.7k](/packages/orptech-laravel-migration-partition)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

101.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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