【问题标题】:How to set Phinx migrations to create migration class with up/down method如何设置 Phinx 迁移以使用 up/down 方法创建迁移类
【发布时间】:2017-06-30 21:53:24
【问题描述】:

您能否告诉我是否可以设置 Phinx 迁移以使用 up/down 方法创建迁移类,而不是更改默认选项? 谢谢。

【问题讨论】:

  • 你可以创建自己的migration template并从命令行提供,但不知道有没有sh phinx create Migration --up-down的东西。
  • 是的,我有。但这并不是我想要的。谢谢。
  • 如果有人不知道,模板你可以通过模板文件中的 $className 设置类名。还可以将模板另存为 txt 文件,以备不时之需。

标签: php database-migration phinx


【解决方案1】:

创建您的own migration template

<?php

use $useClassName;

class $className extends $baseClassName
{
    public function up() {

    }

    public function down() {

    }
}

然后在配置中应用:

paths:
    migrations:
        - application/module1/migrations
templates:
    file: <your-custom-tmplate.path>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-07
    • 1970-01-01
    • 2019-12-20
    • 2012-08-29
    • 2015-07-03
    • 2018-11-14
    相关资源
    最近更新 更多