问题描述
我为我的迁移创建了一个基类.目前我运行 artisan migrate 命令,它创建了一个扩展 Migrations 文件的新迁移,但是我想包含我的 BaseMigration 并从那里扩展它.我一直在手动进行此更改,但我觉得我在不必要地重复自己.
I've created a base class for my migrations. At the moment I run the artisan migrate command and it creates a new migration that extends the Migrations file, however I want to include my BaseMigration and extend it from there. I've been making this changes manualy but I feel like I'm repeating myself unnecessarily.
关于如何让新迁移自动扩展和加载我的基础迁移有什么建议吗?
Any advice on how to have new migrations automatically extend and load my base migration?
推荐答案
我不认为你可以,因为 Laravel 从 vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs 文件夹,你不能改变它,但你有一些选择:
I don't think you can, because Laravel takes migrations from the vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs folder and you cannot change that, but you have some options:
1) 创建您自己的工匠命令migrate:makemyown.
1) Create your own artisan command migrate:makemyown.
2) 使用 Jeffrey Way 的 Laravel 生成器.他们让您通过以下方式创建迁移:
2) Use Jeffrey Way's Laravel Generators. They let you create your migrations by doing:
php artisan generate:migration create_posts_table --fields="title:string, description:text"
如果您只有一些需要开始的字段,而不是更具体的字段,那么它真的很好.
If you just have some fields you need to start with and not something more specific than that, it works really fine.
3) 编辑 Laravel 存根,但问题是一旦你 composer update 它们可能会被 Composer 覆盖.
3) Edit Laravel stubs, but the problem is that as soon as you composer update they might get overwritten by Composer.
这篇关于可以修改由 artisan migrate 命令创建的模板吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)