2
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 6.x migrations-generatorがインストールできない問題対応

Posted at

既存DBのmigrationsファイルを作成したい

migrations-generatorをインストールする

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

larabel 6.xでは下記のようなエラーになる

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - xethron/migrations-generator v2.0.0 requires way/generators dev-feature/laravel-five-stable -> no matching package found.
    - illuminate/support v5.7.9 requires nesbot/carbon ^1.26.3 -> satisfiable by nesbot/carbon[1.26.3, 1.26.4, 1.26.5, 1.26.6, 1.27.0, 1.28.0, 1.29.0, 1.29.1, 1.29.2, 1.30.0, 1.31.0, 1.31.1, 1.32.0, 1.33.0, 1.34.0, 1.34.1, 1.34.2, 1.34.3, 1.34.4, 1.35.0, 1.35.1, 1.36.0, 1.36.1, 1.36.2, 1.37.0, 1.37.1, 1.38.0, 1.38.1, 1.38.2, 1.38.3, 1.38.4, 1.39.0, 1.39.1] but these conflict with your requirements or minimum-stability.
   
    (省略)

    - don't install illuminate/support v5.0.4|don't install laravel/framework v6.18.20
    - Installation request for laravel/framework (locked at v6.18.20, required as 6.x) -> satisfiable by laravel/framework[v6.18.20].
    - Installation request for xethron/migrations-generator ^2.0 -> satisfiable by xethron/migrations-generator[v2.0.0, v2.0.1, v2.0.2].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

ググると同じ問題に直面してるひとが多数。(https://github.com/Xethron/migrations-generator/issues/191)
これや https://github.com/oscarafdev/migrations-generator

composer require oscarafdev/migrations-generator --dev

これを https://github.com/kitloong/laravel-migrations-generator

composer require --dev "kitloong/laravel-migrations-generator"

試してみろと書かれているのがこれらもうまく行かない・・・

解決方法

laravelのバージョンの互換性の問題だしlaravelのバージョン下げてしまえばいい
そりゃそうでしょって話だが今回migrationsファイル作るだけなので
別プロジェクトをlaravel5.4で立ち上げてそこで作ったものをコピーすれば良いと考えた

Version指定してlaravelをインストール

composer create-project "laravel/laravel=5.4.*" sampleproject
cd sampleproject
composer require oscarafdev/migrations-generator --dev

うまくインストールできた。
app.phpに下記を追加して

config/app.php
Way\Generators\GeneratorsServiceProvider::class,
Xethron\MigrationsGenerator\MigrationsGeneratorServiceProvider::class,

.envを修正して既存DBにつなげたあと

php artisan migrate:generate
Do you want to log these migrations in the migrations table? [Y/n] :
 > Y

 Next Batch Number is: 2. We recommend using Batch Number 0 so that it becomes the "first" migration [Default: 0] :
 > 0

でmigrationsファイル作成してくれました

ちなみに

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

でテーブルの指定ができて

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

で実行しないテーブルの指定ができるみたいです。

互換性の問題ってわかってるならあれこれやる前にバージョン下げてしまえばよいだけの話でした

2
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
2
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?