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 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
    • ¥15 再不同版本的系统上,TCP传输速度不一致
    • ¥15 高德地图点聚合中Marker的位置无法实时更新
    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式