kitloong / laravel-migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
2.43k stars 269 forks source link

log and migration path #177

Closed blondie63 closed 1 year ago

blondie63 commented 1 year ago

Hi, i've tried this command: php artisan migrate:generate --tables=“companies” —path=/app/database/migrations/tmp/ Using connection: mysql

Generating migrations for:

Do you want to log these migrations in the migrations table? (yes/no) [yes]:

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

Setting up Tables and Index migrations.

Setting up Views migrations.

Setting up Stored Procedures migrations.

Setting up Foreign Key migrations.

Finished!

The response is OK but no migration is created and also no logs Whats wrong ?

Thanks

kitloong commented 1 year ago

Hi @blondie63

Please review your command:

php artisan migrate:generate --tables=“companies” —path=/app/database/migrations/tmp/

The hyphen you used for —path is not correct.

blondie63 commented 1 year ago

Ok thanks, anyway the return message is wrong, input parameters are not validated ? :) Looking your docs i saw we can use -t or --tables , -p or --path, i've tried: php artisan migrate:generate -t=“companies” -p=/app/database/migrations/tmp php artisan migrate:generate --tables=“companies” --path=/app/database/migrations/tmp

I've deleted the previous migration I also tried with a wrong table name but in all cases no migration are generated and the re return msg is:

Setting up Tables and Index migrations. Setting up Views migrations. Setting up Stored Procedures migrations. Setting up Foreign Key migrations. Finished!

very strange

kitloong commented 1 year ago

Hi @blondie63 , thanks for reply.

First of all, this is not the correct way to use shortcut option

php artisan migrate:generate -t=“companies” -p=/app/database/migrations/tmp

Please read https://laravel.com/docs/10.x/artisan#option-shortcuts

Second, you are using wrong double quote

php artisan migrate:generate --tables=“companies” --path=/app/database/migrations/tmp

Please use "

In fact, you can use options without ", please read https://laravel.com/docs/10.x/artisan#options-with-values

Finally, if you are using the correct command, it should be like the following:

php artisan migrate:generate --tables="not_found" --path=/app/database/migrations/tmp

Because you are providing a "not exists" table name, the generator complete the process without any migration file is expected.

However, I do agree a better message can provide clearer feedback to the user. I will consider update the message in near future.

blondie63 commented 1 year ago

Ok using the right quote generation is ok but on your docs example you wrote: --path=/app/database/migrations this path seems to imply that he is using a relative path when in fact he is using an absolute one, maybe you should update the documentation

Normally the user who uses this generator is on the root of the application and therefore the most correct command should be this:

php artisan migrate:generate --tables="companies" --path=database/migrations/tmp

Do you agree ?

kitloong commented 1 year ago

@blondie63 Thanks for your suggestion.

However, where do you read this?

--path=/app/database/migrations

I can't find this from the README.md, nor anywhere from the source code. If you believe it is written in the documentation, could you please share with me the link?

Anyway, it is up to the user to use absolute or relative path, you can set the --path value on your demand.

Extra note: --path is optional, by default, migrations will be generated to database/migrations/.

kitloong commented 1 year ago

This issue is being closed as there has been no response from the author.