redbastie/laravel-auto-migrate

为您的Laravel模型提供自动迁移。

1.0.0 2021-01-18 12:38 UTC

This package is auto-updated.

Last update: 2024-09-29 05:43:08 UTC


README

此包不再维护。请考虑以下最新包: https://github.com/redbastie/tailwire

Laravel 自动迁移

为您的Laravel模型提供自动迁移。

安装

通过composer安装

composer require redbastie/laravel-auto-migrate

工作原理

migrate:auto命令将自动比较您的数据库并使用Doctrine应用必要的更改。

用法

在您的Laravel模型中指定一个migration方法

class Vehicle extends Model
{
    use HasFactory, FillsColumns;

    public function migration(Blueprint $table)
    {
        $table->id();
        $table->string('name');
        $table->timestamps();
    }
}

运行migrate:auto命令

php artisan migrate:auto --fresh --seed

注意,--fresh--seed是可选的。

传统迁移

migrate:auto命令将在自动迁移方法之前运行您的传统迁移文件。