Previous migrations reverted & new migrations are not processed as of v0.12.0
I'm not sure how to describe this problem, but I know exactly which release causes the issue and I'm assuming something has changed that is affecting my environment, but looking at the code, I do not see how.
Up to v0.12.0 (https://github.com/cakephp/phinx/releases/tag/0.12.0), everything works fine. Starting in version v0.12.0, some of my migrations are being reverted (back to about July), and new ones are not processed.
I changed the default_database to default_environment, fairly certain that would have no effect, and it did not.
Could you provide the following information?
- What database adatper are you using (mysql, postgres, etc.)?
- A list of affected migration file names (or at least the date part of the filename)
- Output of running
php -r "echo (PHP_INT_SIZE == 4 ? '32 bit' : '64 bit').PHP_EOL;"on the affected system
mysql
20200819215644_ticket119655.php 20200808143405_ticket118943.php
C:\windows\system32>php -r "echo (PHP_INT_SIZE == 4 ? '32 bit' : '64 bit').PHP_EOL;" 64 bit
Just updated to 0.12.7 and I still have this issue.
I am trying to debug the issue, but I can't figure out a way to get XDebug to work with this and I can't get any output to display.
I found the issue:


The "target" option for is returns this value:
string(70) "C:/inetpub/Intranet_Local/bin//../library/phinx_migration_template.txt" bool(true)
Which that code above converts it to zero - since it's a zero and not NULL (which is default), then this thinks I'm trying to migrate down (we never migrate down):

What is "target", how do I set it back to null / 0 / default?
How are you calling phinx? If using the CLI, target should only be set if you were to do phinx migrate --target foo, though not sure if it's a feature or bug that doing migrate --target 0 allows for rolling back. I would lean towards the latter. Thoughts @dereuromark?
Oh, I am using the parameter -t from the command line, which is supposed to be to set the template:
c:/PHP/php.exe -cc:/PHP/devrc/php.ini c:/jenkins-php-tools/phinx_run.php -t"%~dp0/../library/phinx_migration_template.txt" %*
But it appears others aspects of the command line are also not working. I see nothing in your release notes about changes to command line parameters.
The -t flag is target for migrate and rollback and then template for create and seed:create commands, and they do not match usage of each other. There is no template option for migrate. My guess would be that in 0.12, some implicit handling was added to coerce it to int which is causing this break whereas before it was just being silently ignored?
Actually, that is not correct. I for a fact that I was using -t so that our new migrations would be created using our own template. To be certain, I just tested it on 0.11.7 and with this:
-t"%~dp0/../library/phinx_migration_template.txt"
I get this (for create):
<?php
use Intranet\Abstracts\PhinxMigration;
require_once __DIR__."/../library/Intranet/Abstracts/PhinxMigration.php";
class Test1 extends PhinxMigration{
public function up():void{
$this->execute(
"");
}
}
Without the -t parameter above, I get this:
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class Test1 extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
}
}
That's what I said. -t does different things depending on the command you're using.
create / seed:create
bin/phinx create --help
Phinx by CakePHP - https://phinx.org.
Description:
Create a new migration
Usage:
create [options] [--] [<name>]
Arguments:
name Class name of the migration (in CamelCase)
Options:
...
-t, --template=TEMPLATE Use an alternative template
...
migrate / rollback
bin/phinx migrate --help
Phinx by CakePHP - https://phinx.org.
Description:
Migrate the database
Usage:
migrate [options]
Options:
...
-t, --target=TARGET The version number to migrate to
...
Don't use -t to pass a template file path to migrate or rollback, as it's expecting a version.
Well, that's what I get for skimming your reply too fast. So we use a wrapper and pass all commands through it - before I could pass the wrapper all commands, but now I can't. I'll have to build some logic to only pass it for create (or use the full command, --template), however, even if we fix that, we other command-line failures now. It sucks there is no comprehensive listing for command line parameters (or I can't find out) - like a list of all the parameters and these are the commands they apply to. In fact, I find nowhere that -t can be used in place of --template. I see the latter on https://book.cakephp.org/phinx/0/en/commands.html, but not the former.