1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Laravel】すでに作成済みのテーブルからマイグレーション作成

Posted at

すでに作成済みのテーブルからLaravelのマイグレーションファイルを作る方法。
migrations-generatorを使用する。
Laravel 6/7/8に対応。

composerのrequireコマンドでパッケージを追加

composerでrequireコマンドを実行。

composer require "oscarafdev/migrations-generator" --dev

migrations-generatorでマイグレーションを作成

すべてのテーブルからマイグレーションを作成

php artisan migrate:generate

指定したテーブルからマイグレーションを作成(複数指定可能)

php artisan migrate:generate table1,table2,table3,table4,table5

特定のテーブルを除外することも可能

php artisan migrate:generate --ignore="table3,table4,table5"

デフォルトではMySQLなので、他を使用の場合は、オプションで指定する。

php artisan migrate:generate --connection="connection_name"

その他、気になったらヘルプを見る。

php artisan help migrate:generate
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?