Phinx: The command "php vendor/bin/phinx create MyNewMigration" is not working.

Created on 17 Jan 2016  路  10Comments  路  Source: cakephp/phinx

It just shows the following. I tried it on the latest version, i.e., version 0.5.1, and on version 0.4.4. I am getting the following with both instead of getting a migration class. I could get "phinx.yml" file; I entered the info for pgsql database. I also could get a migrations folder which is empty.

dir=$(d=${0%[/]*}; cd "$d"; cd '../robmorgan/phinx/bin' && pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
# Cygwin paths start with /cygdrive/ which will break windows PHP,
# so we need to translate the dir path to windows format. However
# we could be using cygwin PHP which does not require this, so we
# test if the path to PHP starts with /cygdrive/ rather than /usr/bin
if [[ $(which php) == /cygdrive/* ]]; then
dir=$(cygpath -m $dir);
fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/phinx" "$@"

Most helpful comment

The content of vendor/bin are runnables. No need to use the PHP loader.

Use vendor/bin/phinx create xxxx where xxxx is the name of the migration you want.

All 10 comments

The content of vendor/bin are runnables. No need to use the PHP loader.

Use vendor/bin/phinx create xxxx where xxxx is the name of the migration you want.

@rquadling I noticed that the tables were created in the directory db/migrations. However, there is an empty migrations directory just after root directory; should I delete that? The content of phinx file is the same as above; I guess it should be like that.

Thanks for your help

The location of the migrations is softcoded. You can set it in your config file (phinx.yml, phinx.php, etc.)

@rquadling Table 'users' and its columns are not being migrated to postgres database. It says: "All Done. Took 0.0367s", but it doesn't show any message indicating migration. Also, my database table is empty; no database table with the name 'users' has been created.
I typed:
vendor/bin/phinx migrate

Can you show your migration script?

Here is the script, originally it was different, then I wrote it the way that it was written on phinx website:

public function up()
{
  $users = $this->table('users');
  $users->addColumn('first_name', 'string', array('limit' => 30))
        ->addColumn('last_name', 'string', array('limit' => 30))
        ->addColumn('email', 'string', array('limit' => 100))
        ->addColumn('password', 'string', array('limit' => 40))
        ->addColumn('created', 'datetime')
        ->addColumn('updated_at', 'datetime', array('null' => true))
        ->save();
}

public function down()
{
  $this->dropTable('users');
}

I commented out "public function change()".

@rquadling I could fix it after I deleted phinxlog from postgress database where 'users' table supposed to be. So I close this issue.

OK.

I got errors even after reading and following the above guideline that vendor/bin is runnable. After searching I realized that on Windows the command is only accepted with backslashes, so the command is only valid as vendor\bin\phinx init. With this command it all worked. Hope it helps some of the Windows users.

Thanks @nicolaib

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amcoho picture amcoho  路  4Comments

otaruMendez picture otaruMendez  路  3Comments

Jeckerson picture Jeckerson  路  3Comments

elct9620 picture elct9620  路  4Comments

J-Fricke picture J-Fricke  路  3Comments