如果 table 在 运行 迁移时存在,laravel 5.2 会吓坏

laravel 5.2 will freak out if table exists when running migrations

我需要变通或检查 table 是否存在。

情况:

我有一个测试站点和一个生产站点,在我创建的测试站点上,运行 一个随着时间的推移创建了 2500 万条记录的任务。这些记录然后从测试数据库中导出并导入到生产中,因此我不必重新 运行 重新执行任务。

这让我可以切换一些逻辑,现在说,做同样的获取,但检查以确保记录不存在,大大提高了整个任务的速度(任务产生大约 125 ish执行 100 次提取的作业拆分为 18 个并发连接)所以这需要一段时间。

因此在生产环境中,迁移会像 "uh this table exists ... sorry crash time"

所以我想说"if table exists ignore the migration, else run the migration for create"

想法?

查看 the documentation,具体来说,它描述了 "Checking For Table / Column Existence":

if (Schema::hasTable('users')) {
    //
}