![]() |
Migrations inside composer scripts - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Migrations inside composer scripts (/showthread.php?tid=80299) |
Migrations inside composer scripts - ARAmiss - 10-14-2021 Hello. I have a composer package. It's like small cms (with db tables). My target is to start migrations after package install/update from composer. In this case I use composer scripts. But there are no any autoloaded classes exist inside it. composer.json: Code: { Velldoris\Database\Migration::install: Code: try { There is an error like "Codeigniter class not defined" while i try to init my method strict ("composer run-script post-install-cmd"). And it's not surprising. Here are the solutions I see: 1) Load all project classes throught composer autoload.php 2) Use mysql dump instead of migrations (really?) RE: Migrations inside composer scripts - includebeer - 10-16-2021 I'm no composer expert, but can't you call "spark migrate -all"? RE: Migrations inside composer scripts - ARAmiss - 10-16-2021 I would like auto start migrations when "composer require ..." and "composer update". Not manual. The composer allows to do this. For example: https://getcomposer.org/doc/articles/scripts.md#executing-php-scripts But the command "spark migrate -all" can be called in the ROOTPATH. How can i call this from project root path? The another way (similar to spark migrate) is to call controller method like this: spark install index spark update index And this is the same question - how to call from root. The way is to create own spark file in the package root. And then we can call it something like this: Code: "scripts": { And how can we pass execution from our package spark to default /project-root-path/spark? RE: Migrations inside composer scripts - ARAmiss - 10-17-2021 About spark. There is FCPATH definition inside it: Code: // Path to the front controller What if my public directory named not "public"? Any idea? RE: Migrations inside composer scripts - includebeer - 10-17-2021 (10-17-2021, 12:39 AM)ARAmiss Wrote: About spark. There is FCPATH definition inside it:In that case you need to edit the spark script. There should be a better way to configure this, but at the moment I think it's the only way to do it. RE: Migrations inside composer scripts - ARAmiss - 10-17-2021 Thank you. Despite it is not very convenient to edit the spark file on each project, apparently this is the only option for now. What about getting the root folder of the project from the composer scripts? Maybe someone has faced such a task? And in general, how does anyone solve the task of starting migrations after install/update package from the composer? Or is it all done by hand from the command line? |