Is it possible to call some facade method from propel migrations ?
Comments
-
$foo = new FoobarFacade()
$foo->bar()
π0 -
(not saying it's a good idea though ... π )
0 -
Tried that lol, Warning: require(APPLICATION_ROOT_DIR/config/Shared/stores.php): failed to open stream: No such file or directory in /var/www/vendor/spryker/kernel/src/Spryker/Shared/Kernel/Store.php on line 152
0 -
oh I guess it isn't bootstrapped for zed, perhaps, maybe just Propel
0 -
Hi Filip, the migration files are executed by Propel directly. So there is no Spryker context and therefore you cannot use Facades here.
0 -
@UKGT7RC7P Direct instantiation of Facades is never a good idea because then eg there is no factory. If you need a facade without DependencyProvider then this is the offical way to get it:
\Spryker\Zed\Kernel\Locator::getInstance()->customer()->facade();
0 -
ah good to know π
0 -
(of course I never instantiated a facade directly ...)
0 -
π
0 -
Filip, in case you need a data migration and the data will be mandatory then you need three steps:
- Adjust the schema (e.g. add a column and set required=βfalseβ)
Implement your data migration somewhere else (e.g. in a Zed controller or CLI command. Itβs throw-away code anyway.
Migrate the schema and migrate your data.Adjust the schema again (e.g. set required=βtrueβ)
0 -
@UKKQKJ9FX in case if you need some data migration functionality you can use Installer plugins, check:
\Spryker\Zed\Installer\Dependency\Plugin\InstallerPluginInterface
and\Pyz\Zed\Installer\InstallerDependencyProvider
0 -
Thanks, will try
0 -
Are you suggesting just to manually run command to migrate data or can command be run from migration? @UKU1E0ENB
0 -
Command can be run during
propel:install
0 -
But you need two deployments for this special case of data migration.
0 -
I personally prefer to have the propel migration files on gitignore so that they are generated on the fly during the deployment. This makes life so much easier when you switch branches during developments or on staging environments. In this case there is no chance to manipulate these files.
0 -
How do you run them during propel:install, from the shell or? It can not be ran from code inside migration ? What about migration down here
0 -
propel:install (or the specific commands behind) should be part of each deployment. Just look into the recipes.
0 -
I never reverted a migration because itβs not safe anyway.
0 -
okay, thanks π
0 -
Can I run the command automatically with the migration during the deploy
0 -
so I don't have to go to container and exec it manually
0 -
yep. there are different approaches though. we prefer generating the migration files, commit them to repo and βonlyβ process the existing ones on deployment. I heard others let propel do the calculation of the diff and the application of the generated migration files during deployment. that removes awareness and visibility of changes to be expected imo
0 -
I think you didn't quite get the question.
I am talking about sprykers console command,
I am using that command (console command) I wrote to transfer data from one table to another existing table that uses json as a value in certain columns so it would be hard to write raw sql queries for that. So after deploy I have to execute that command manually but I don't want to.
Any ideas ? ( Would like to combine that with propel migration)0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 69 Spryker News
- 899 Developer Corner
- 760 Spryker Development
- 83 Spryker Dev Environment
- 361 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 24 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 68 Spryker Safari Questions
- 50 Random