The migration is created, but it doesn't contain the user-defined columns automatically. I need help dynamically modifying the migration file before running migrate. Is there a better approach to save schema details and ensure the migration reflects user input?
The user provides input. A migration file is generated with user-defined columns. The schema details are stored in storage/schemas/{tableName}.txt.
The migration is created, but it doesn't contain the user-defined columns automatically. I need help dynamically modifying the migration file before running migrate. Is there a better approach to save schema details and ensure the migration reflects user input?
The user provides input. A migration file is generated with user-defined columns. The schema details are stored in storage/schemas/{tableName}.txt.
Share Improve this question asked Mar 10 at 19:13 Hamza AmeerHamza Ameer 11 bronze badge 1- Hi there. Migrations are meant to be defined by the developers manually. There might be a package to dynamically generated them, but I won't recommend since others developers won't have the same database schema with others. – Tatachiblob Commented Mar 10 at 23:20
1 Answer
Reset to default -1You can use a stub file for the migration file creation and then run php artisan migrate
.
Here is a package that makes stub customization easy: https://laravel-news/laravel-stub
I will not judge if letting the user trigger a table creation is a good practice or not... it is not.