【问题标题】:Cant create migration phinx无法创建迁移 phinx
【发布时间】:2021-10-01 23:27:34
【问题描述】:

当我尝试创建迁移时,我得到了这个异常,但我的迁移路径中没有花括号

[例外] 您可能使用花括号在 Phinx 配置文件中定义迁移路径,但没有使用此模式匹配的目录。您需要手动创建迁移目录。

我的配置:

paths:
  migrations: %%PHINX_CONFIG_DIR%%/db/migrations
  seeds: %%PHINX_CONFIG_DIR%%/db/seeds

environments:
  default_migration_table: phinxlog
  default_database: development
  production:
    adapter: mysql
    host: localhost
    name: production_db
    user: root
    pass: ''
    port: 3306
    charset: utf8

  development:
    adapter: mysql
    host: localhost
    name: development_db
    user: root
    pass: ''
    port: 3306
    charset: utf8

  testing:
    adapter: mysql
    host: localhost
    name: testing_db
    user: root
    pass: ''
    port: 3306
    charset: utf8

version_order: creation

【问题讨论】:

    标签: php mysql phinx


    【解决方案1】:

    在尝试设置 CakePHP 和 Phinx 时遇到了同样的错误。 是由于在运行 Phinx 命令时丢失了目录造成的。 文档说要初始化系统类型:

    phinx init .
    

    (如果 Phinx 是通过 composer 安装的,请使用:vendor/bin/phinx init .

    如果您错过了“。”你得到你描述的错误。看起来 Phinx 没有使用当前工作目录的默认设置。 http://docs.phinx.org/en/latest/commands.html#the-init-command。 您可以通过重新运行 Phinx 命令或手动创建文件夹来解决此问题:

    mkdir -p db/migrations db/seeds
    

    希望这对以后搜索的人有所帮助。

    【讨论】:

      【解决方案2】:

      不确定您是否找到了答案,但我通过在根目录中手动创建 db/migrations 目录来修复此错误。您可能必须对 db/seeds 执行相同操作。

      【讨论】:

      • 文档说你必须创建db/migrations 然后运行vendor/bin/phinx init,然后运行vendor/bin/phinx create ...
      【解决方案3】:

      您可能正在迁移目录中运行“php vendor/bin/phinx”。从根目录试试这个。我遇到了同样的错误并从根文件夹修复。

      【讨论】:

        【解决方案4】:

        如果您使用的是 CakePHP 3.0 或 4.0,您的 paths 可能需要更新..

            'paths' => [
                'migrations' => '%%PHINX_CONFIG_DIR%%/config/Migrations',
                'seeds' => '%%PHINX_CONFIG_DIR%%/config/Seeds'
            ],
        

        为我工作。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-11-14
          • 2018-03-06
          • 1970-01-01
          • 2020-04-13
          • 2022-06-14
          • 1970-01-01
          • 1970-01-01
          • 2022-10-25
          相关资源
          最近更新 更多