我有一个laravel应用程序,它使用的数据库是通过原始SQL脚本迁移的,而不是php迁移。
对于本地开发和测试,我想把这些脚本挂接到php artisan migrate
上,我希望每次有人运行php artisan migrate
时,laravel会收集这些脚本并运行所有以前没有运行过的脚本。
一种方法是为每个脚本创建一个php迁移文件,但我想知道我是否可以挂钩到收集迁移文件的过程中动态地完成这一点。
我尝试在AppServiceProvider
中注册我自己的Migrator
示例,但这似乎不起作用。
1条答案
按热度按时间k10s72fa1#
字符串
型
型
php artisan migrate
命令的一部分运行,则可以扩展MigrateCommand
或侦听MigrationsEnded
事件(如果可用),并在正常迁移完成后触发SQL迁移。PS:我把这些代码从我的老项目。您可以修改它,由于您的需要。