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

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

问题描述

我不想在laravel 4上运行所有未完成的迁移".我有5个迁移.现在,我只想运行一次迁移. 而不是:php artisan migration 我想运行一个特定的迁移,例如:php artisan migration 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脚本并在Web服务器上手动执行它.

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.

如果只需要对它们重新排序,则将文件重命名为第一个.迁移是使用timestemp创建的:

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天全站免登陆