Replies: 4 comments 4 replies
-
This approach is good for a one-time start. Now imagine three cases:
If you need to create migrations from existing tables, it's easier to use the https://github.com/kitloong/laravel-migrations-generator package, for example. |
Beta Was this translation helpful? Give feedback.
-
@agus24 I think this is bull's eye: https://github.com/toramanlis/laravel-implicit-migrations @andrey-helldar i think all three points are covered as well. when the command is run, the existing migrations are taken into account and the differences make another migration. it allows custom migrations as well. say you renamed a column. you can create a migration file that reflects that. as far as the generator is concerned the column name won't even have been renamed. if you want to update the model to match the rename, you can make the custom migration with the rename visible to the generator too. it's up to you if you need to rollback a migration and change it, it works as usual. you don't have to delete the migration and regenerate it, you can just update it, and it works. |
Beta Was this translation helpful? Give feedback.
-
@toramanlis laravel is not symfony to define attributes (as in columns from db) as model php properties. You will have clashes with the active record's php properties. |
Beta Was this translation helpful? Give feedback.
-
Can you elaborate? Why does it have to be symfony to do that? do you mean active record's php attributes? why would i have to worry about clashing with them? Have you checked the package? I've already implemented this and tested it. It doesn't define any properties to clash with anything, neither it hacks the |
Beta Was this translation helpful? Give feedback.
-
Hi. i have an idea can we use php attributes for creating migration from model only?
Our model would looks like
and just call
php artisan generate:migration
and this would generate migration file withup
anddown
methods automaticallyyou can have an annotation when access the model and also create the model with migration inside of it. And it would be great if the
generate:migration
command would read the changes of the model then create migration file that will update the tableBeta Was this translation helpful? Give feedback.
All reactions