迁移在执行下一次迁移之前调用播种器

时间:2018-01-22 13:28:13

标签: php database-migration phinx

使用Phinx有一种方法可以在下次迁移之前调用特定的迁移器吗?

以何种方式以编程方式在迁移中调用播种器?

1 个答案:

答案 0 :(得分:0)

不确定是否是最好的方法,但是解决了创建另一个PHP脚本的问题,该脚本实例化Phinx类并调用迁移和种子符合所需。

$pdo = new PDO($configs['db']['dsn'], $configs['db']['username'], $configs['db']['password'], [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
]);
$config = new Config($configArray);
$manager = new Manager($config, new S

$config = new Config($configArray);
$manager = new Manager($config, new StringInput(' '), new ConsoleOutput());

$manager->migrate($environment, 20170825142637);
$manager->seed($environment, 'UserSeeder');
$manager->migrate($environment, 20170929000000);
$manager->seed($environment, 'ProductSeeder');
$manager->migrate($environment);