运行一个特定的 Laravel 迁移(单个文件) [英] Running one specific Laravel migration (single file)

查看:14
本文介绍了运行一个特定的 Laravel 迁移(单个文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想在 laravel 4 上运行所有未完成的迁移.我有 5 个迁移.现在我只想运行一次迁移.而不是这样做:php artisan migrate我想运行一个特定的迁移,例如: php artisan migrate MY_MIGRATION_TO_RUN

I don't want to run All Outstanding Migrations on laravel 4. I have 5 migrations. Now I just want to run one migration. instead of doing : php artisan migrate I would like to run one specific migration like : php artisan migrate MY_MIGRATION_TO_RUN

推荐答案

看来你做错了.

迁移由 Laravel 逐一执行,按照它们创建的确切顺序,因此它可以跟踪执行和执行顺序.这样,Laravel 将能够安全地回滚一批迁移,而不会有破坏数据库的风险.

Migrations were made to be executed by Laravel one by one, in the exact order they were created, so it can keep track of execution and order of execution. That way Laravel will be able to SAFELY rollback a batch of migrations, without risking breaking your database.

赋予用户手动执行它们的权力,让用户无法(确定)知道如何回滚数据库中的更改.

Giving the user the power to execute them manually, make it impossible to know (for sure) how to rollback changes in your database.

如果你真的需要在你的数据库中执行某些东西,你最好创建一个 DDL 脚本并在你的网络服务器上手动执行它.

If your really need to execute something in your database, you better create a DDL script and manually execute it on your webserver.

或者只是创建一个新的迁移并使用 artisan 执行它.

Or just create a new migration and execute it using artisan.

如果你需要先运行它,你需要先创建它.

If you need to run it first, you need to create it first.

如果您只需要重新排序,请将文件重命名为第一个.迁移是使用时间创建的:

If you just need to reorder them, rename the file to be the first. Migrations are created with a timestemp:

2013_01_20_221554_table

要在此之前创建一个新迁移,您可以命名它

To create a new migration before this one you can name it

2013_01_19_221554_myFirstMigration

这篇关于运行一个特定的 Laravel 迁移(单个文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆