douyun1972 2019-07-03 13:16
浏览 65

当我使用laravel的`RefreshDatabase`特性通过phphunit运行数据库迁移时,Laravel指定一个迁移文件夹

I am migrating my application from Codeigniter into laravel, also we are in the process of making itegration and unit tests as well.

The database is consisted of 2 databases:

  • old That is the one used from the original codeigniter.
  • new That is used for other features not related in the codeingiter project.

Therefore I want to make a migration script used for the old database, but in order to avoid breakdowns I want to specify a specific folder for the migration scripts for each database.

Therefore I found this tool: https://github.com/Xethron/migrations-generator and via this help output:

Description:
  Generate a migration from an existing table structure.

Usage:
  migrate:generate [options] [--] [<tables>]

Arguments:
  tables                              A list of Tables you wish to Generate Migrations for separated by a comma: users,posts,comments

Options:
  -c, --connection[=CONNECTION]       The database connection to use. [default: "etable_api"]
  -t, --tables[=TABLES]               A list of Tables you wish to Generate Migrations for separated by a comma: users,posts,comments
  -i, --ignore[=IGNORE]               A list of Tables you wish to ignore, separated by a comma: users,posts,comments
  -p, --path[=PATH]                   Where should the file be created?
      --defaultIndexNames             Don't use db index names for migrations
      --defaultFKNames                Don't use db foreign key names for migrations
  -h, --help                          Display this help message
  -q, --quiet                         Do not output any message
  -V, --version                       Display this application version
      --ansi                          Force ANSI output
      --no-ansi                       Disable ANSI output
  -n, --no-interaction                Do not ask any interactive question
      --env[=ENV]                     The environment the command should run under
  -tp, --templatePath[=TEMPLATEPATH]  The location of the template for this generator
  -v|vv|vvv, --verbose                Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

I can use the following command sequence in order to make a dedicated folder for the migration script:

mkdir -p ./database/migration/old
php artisan migrate:generate -c old -p ./database/migration/old

And via artisan I can run the migrations via:

php artisan migrate -c old -p ./database/migration/old

Therefore I can use the laravel provided solution:

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class ExampleTest extends TestCase
{
    use RefreshDatabase;

    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
      // Do some fancy stuff here
    }
}

But how I can specify the specified folder for the migration script of the database that I want to participate in test when using the Illuminate\Foundation\Testing\RefreshDatabase?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记