Generating migration file from my custom Symfony command #9872
Unanswered
munteanuserban
asked this question in
Support Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I want to be able to create a migration file in Symfony ( the one with Version ) after I trigger some command from console via php bin/console. In that php file in up function should be my custom query that I wanted to be executed and the reverse in down function as well, basically an insert and delete query.
After some digging I found out some possible workaround but I want to know if there are other solutions that I didn't discover yet.
So my approach:
vendor/doctrine/migrations/lib/Doctrine/Migrations/Generator/Generator.php -> call the method generateMigration with fqcn, up and down paramaters .
For "up" I should add sprintf('$this->addSql(%s);', $UpQuery);
For "down" I should add sprintf('$this->addSql(%s);',$DownQuery);
But for "fqcn" I don't know what to put, I will be in namespace App\Command so I should put the MyCommand className ?
What do you thinks guys of this solution and if you know any better of doing it I will apreciate an answer.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions