PHPackages                             bastinald/laravel-automatic-migrations - 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. bastinald/laravel-automatic-migrations

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

bastinald/laravel-automatic-migrations
======================================

Automatic Laravel model migrations.

3.0.1(4y ago)461.6k12[8 issues](https://github.com/bastinald/laravel-automatic-migrations/issues)[1 PRs](https://github.com/bastinald/laravel-automatic-migrations/pulls)3MITPHP

Since Apr 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/bastinald/laravel-automatic-migrations)[ Packagist](https://packagist.org/packages/bastinald/laravel-automatic-migrations)[ Docs](https://github.com/bastinald/laravel-automatic-migrations)[ RSS](/packages/bastinald-laravel-automatic-migrations/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (3)Versions (45)Used By (3)

Laravel Automatic Migrations
============================

[](#laravel-automatic-migrations)

Instead of having to create and manage migration files, this package allows you to specify your migrations inside your model classes via a `migration` method. When you run the `migrate:auto` command, it uses Doctrine to compare your model `migration` methods to the existing schema, and applies the changes automatically.

This package works fine alongside traditional Laravel migration files, for the cases where you still need migrations that are not coupled to a model. When you run the `migrate:auto` command, it will run your traditional migrations first, and the automatic migrations afterwards.

Documentation
-------------

[](#documentation)

- [Installation](#installation)
- [Usage](#usage)
- [Commands](#commands)
    - [Making Models](#making-models)
    - [Running Migrations](#running-migrations)
- [Migration Order](#migration-order)
- [Publishing Stubs](#publishing-stubs)

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

[](#installation)

Require the package via composer:

```
composer require bastinald/laravel-automatic-migrations
```

Usage
-----

[](#usage)

Declare a `migration` method in your models:

```
namespace App\Models;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Eloquent\Model;

class MyModel extends Model
{
   public function migration(Blueprint $table)
   {
       $table->id();
       $table->string('name');
       $table->timestamp('created_at')->nullable();
       $table->timestamp('updated_at')->nullable();
   }
}
```

Run the `migrate:auto` command:

```
php artisan migrate:auto
```

Commands
--------

[](#commands)

### Making Models

[](#making-models)

Make a model with a `migration` method included:

```
php artisan make:amodel {class} {--force}
```

This command will also make a factory whose `definition` points to the model method. Use `--force` to overwrite an existing model.

### Running Migrations

[](#running-migrations)

Run automatic migrations:

```
php artisan migrate:auto {--f|--fresh} {--s|--seed} {--force}
```

Use `-f` to wipe the database, `-s` to seed after migration, and `--force` to run migrations in production.

Migration Order
---------------

[](#migration-order)

You can specify the order to run your model migrations by adding a public `migrationOrder` property to your models. This is useful for pivot tables or situations where you must create a certain table before another.

```
class MyModel extends Model
{
    public $migrationOrder = 1;

    public function migration(Blueprint $table)
    {
        $table->id();
        $table->string('name');
        $table->timestamp('created_at')->nullable();
        $table->timestamp('updated_at')->nullable();
    }
}
```

The `migrate:auto` command will run the automatic migrations in the order specified. If no order is declared for a model, it will default to `0`. Thanks to [@vincentkedison](https://github.com/vincentkedison) for this idea.

Publishing Stubs
----------------

[](#publishing-stubs)

Use your own model and factory stubs by publishing package files:

```
php artisan vendor:publish --tag=laravel-automatic-migrations
```

Update the `stub_path` in `config/laravel-automatic-migrations.php`:

```
'stub_path' => resource_path('stubs/vendor/laravel-automatic-migrations'),
```

Now edit the stub files inside `resources/stubs/vendor/laravel-automatic-migrations`. Commands will now use these stub files to make models and factories.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~3 days

Recently: every ~10 days

Total

44

Last Release

1746d ago

Major Versions

1.2.6 → 2.0.02021-06-30

2.4.0 → 3.0.02021-09-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/82109804?v=4)[bastinald](/maintainers/bastinald)[@bastinald](https://github.com/bastinald)

---

Top Contributors

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

---

Tags

databaseeloquentlaravellaravel-modelsmigrationsmodelphp

### Embed Badge

![Health badge](/badges/bastinald-laravel-automatic-migrations/health.svg)

```
[![Health](https://phpackages.com/badges/bastinald-laravel-automatic-migrations/health.svg)](https://phpackages.com/packages/bastinald-laravel-automatic-migrations)
```

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.6M217](/packages/backpack-crud)[tpetry/laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features

1.0k2.3M27](/packages/tpetry-laravel-postgresql-enhanced)[nasirkhan/laravel-starter

A CMS like modular Laravel starter project.

1.4k2.7k](/packages/nasirkhan-laravel-starter)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135212.4k7](/packages/statamic-rad-pack-runway)[ronasit/laravel-entity-generator

Provided console command for generating entities.

2052.5k](/packages/ronasit-laravel-entity-generator)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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