最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - How to Create a Table via Laravel Console Command and Save Schema to a Text File - Stack Overflow

programmeradmin4浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default -1

You 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.

发布评论

评论列表(0)

  1. 暂无评论