Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0.0-2.0.4] Bake migration_snapshot throws exception when trying to mark migrated #428

Open
challgren opened this issue Jan 26, 2020 · 6 comments
Labels
bug

Comments

@challgren
Copy link

@challgren challgren commented Jan 26, 2020

So I created a new app following the instructions on cakephp/app and when baking my first migration using the bin/cake bake migration_snapshot Initial the following exception is generated. However the migration file is generated but the phinx tables are not generated and the migration is not marked as applied. I'm not sure if this should be reported in cakephp/cakephp or cakephp/migrations or here. However if I do bin/cake migrations mark_migrated the phinx table is generated and the migration is mark as migrated. I know @WrDX on Slack was also experiencing this issue.

When I first created my original 4.x app I was able to successfully bake a migration and it be run. That migration is dated 20191222 so I'm not sure if something changed in the past month that would be causing this new error.

Mac-mini:bequest challgren$ bin/cake bake migration_snapshot Initial

Creating file /Users/challgren/Projects/bequest/config/Migrations/20200126121547_Initial.php
Wrote `/Users/challgren/Projects/bequest/config/Migrations/20200126121547_Initial.php`
Marking the migration 20200126121547_Initial as migrated...
Exception: Shell class for "Migrations" could not be found. If you are trying to use a plugin shell, that was loaded via $this->addPlugin(), you may need to update bin/cake.php to match https://github.com/cakephp/app/tree/master/bin/cake.php
In [/Users/challgren/Projects/bequest/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php, line 332]
@WrDX
Copy link

@WrDX WrDX commented Jan 28, 2020

I was the one asking about the issue on Slack @challgren, you might want to edit your answer so the Wouter you tagged won't get bothered with updates ;)

Is there a way to work around this until it's fixed?

@challgren
Copy link
Author

@challgren challgren commented Jan 28, 2020

Run bin/cake migrations mark_migrated after you bake your migration_snapshot/diff

@saeideng saeideng transferred this issue from cakephp/bake Jan 28, 2020
@saeideng
Copy link
Member

@saeideng saeideng commented Jan 28, 2020

I transferred the issue to correct place

and I wanna convert this shell/task (mark_migrated) to command soon

@Ali1
Copy link

@Ali1 Ali1 commented Feb 29, 2020

Also the schema lock is not being updated which causes problems for further migration_diff generation.

@Ali1
Copy link

@Ali1 Ali1 commented Feb 29, 2020

As a workaround modify SnapshotTrait.php and replace 2 lines around line 66 with

        $this->_io->out('Marking the migration ' . $fileName . ' as migrated...');
        debug($dispatchCommand);
        //$this->dispatchShell($dispatchCommand);

And around line 87 with:


        $this->_io->out('Creating a dump of the new database state...');
        debug($dispatchCommand);
        //$this->dispatchShell($dispatchCommand);

This will output two commands that you can use and run manually (bin/cake .....) to achieve normal behavior

@dereuromark
Copy link
Member

@dereuromark dereuromark commented Apr 11, 2020

PR welcome if this is still an issue.

@dereuromark dereuromark added the bug label Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.