Can't get migration in module to be recognised by spark migrate --all |
I have modules separate to the app namespace. I'm following the instructions about modules and trying to run a migration that lives under my own namespace, but spark migrate is completely ignoring it and I can't figure out why.
My file structure: app midair system I have the following code: app/Config/Autoload.php PHP Code: public $psr4 = [ midair/Article/Database/Migrations/2025-01-07-195230_CreateArticle.php PHP Code: namespace Midair\Article\Database\Migrations; And then when my server starts I'm executing Code: php spark migrate --all I've tested moving the migration into app/Database/Migrations (and adjusting the namespace) and it works fine, but for some reason it's refusing to see the migration when it lives under my own namespace. I also tried running php spark migrate -n Midair\\Article and that also didn't work.
Please wait until the end of day, I' am working on and testing this out now.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
PHP Code: 'Midair\Article' => ROOTPATH . 'midair/Article', There is a bug with the Seeder and Module which has been reported. The Module Migrations work just fine if your Autoload namespaces are correct, this has just been tested by me. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Even though my folder name is lowercase? Why would that work?
Edit: I tried your suggestion and it didn't make any difference. I also tried renaming my module folder to capitalized Midair, same thing.
Update: I've verified that a Route added under midair/Article/Config.Routes.php works fine, so the app is correctly detecting the autoloaded namespace. It's just the migration from that module that isn't being seen by the php spark call.
I'm executing the php spark --all call on a Docker instance, but I don't see how that can make any difference (and I've already seen it run migrations that are under app). (PS: Why are you replying to me but not approving my moderated posts?)
You have to pass the name space with the Seeder:
Code: php spark db:seed Modules\YourModuleName\Database\Seeds\YourSeederName What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Solved the problem. Entirely my dumb fault - I had changed the php spark migrate call in my Dockerfile, but had forgotten to rebuild the image. Now it's working as expected. Thanks for your help.
|
Welcome Guest, Not a member yet? Register Sign In |