Cant create migration phinx

Viewed 4802

When I try create migration I get this exception, but I have not got curly braces in my migration path

[Exception] You probably used curly braces to define the migration path in your Phinx configuration file, but no directories have been matched using this pattern. You need to create a migration directory manually.

My config:

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
4 Answers

Just came across this same error when trying to setup CakePHP & Phinx. Was caused by missing out the directory when running the Phinx command. Docs say to init the system type :

phinx init .

(If Phinx was installed via composer use : vendor/bin/phinx init . )

If you miss out the '.' you get the error you have described. It looks like Phinx doesn't have a default setting of using the currently working directory. http://docs.phinx.org/en/latest/commands.html#the-init-command. You can fix the issue by ether re-running the Phinx command or by manually creating the folders :

mkdir -p db/migrations db/seeds

Hope this helps anyone searching in the future.

Probably you are running "php vendor/bin/phinx " from inside the migration directory. Try this from root directory. I was getting same error and fixed from root folder.

If you are using CakePHP 3.0 or 4.0 your paths might need updating..

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

Worked for me.

Related