![]() |
AbuseIPDB Module - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forumdisplay.php?fid=34) +--- Thread: AbuseIPDB Module (/showthread.php?tid=93095) |
AbuseIPDB Module - grimpirate - 07-02-2025 I'm working on a module for CodeIgniter4 to provide ip blocking: https://github.com/grimpirate/abuseipdb I've run into an issue where I have a migration located under modules/AbuseIpdb/Database/Migrations. After completing the setup and creating the SQLite database (php spark db:create abuseipdb --ext db) I attempt: php spark migrate It's my understanding from the docs that migrations are auto-detected and run across every namespace. However, in practice, that did not occur. My migrations do not run. If I move the file from modules/AbuseIpdb/Database/Migrations into app/Database/Migrations and run the migration then it works (even without changing the namespace). What am I doing wrong here? RE: AbuseIPDB Module - InsiteFX - 07-02-2025 I use Lonnie's Shield migrations setup for my modules and it works fine. Take a look at how Lonnie does it in Shield for a module. Also check out your app/Config/Modules.php file. RE: AbuseIPDB Module - grimpirate - 07-02-2025 Replicating shield's structure won't change what's occurring here. The underlying issue is that a migration is failing to process within a module. app/Config/Modules.php is unchanged (nor should it require any modification). The only things that should be required to have a database migration in a module work are:
Code: notebook@hbfnc:/var/www$ php spark migrate Which shows that the namespace is correct and that the migration table is being detected, but the migration isn't being processed. You can see a full demonstration of the project here that clearly shows the lack of creation of the 'confidence' table within the abuseipdb.db sqlite3 database. If I mv the migration file into app/Database/Migrations and run the migrations: Code: notebook@phkh2:/var/www$ php spark migrate Two things are notable here (apart from the obvious that there's nothing wrong with the migration file itself):
RE: AbuseIPDB Module - InsiteFX - 07-03-2025 You can also use spark migrate --all to include migrations from all namespaces. PHP Code: For Unix: Try that and see if it works. If that doe's not work then I would report it on GitHub as a bug. RE: AbuseIPDB Module - grimpirate - 07-03-2025 Thank you for the help InsiteFX. The nuances of performing a migration on the command line leave much to be desired. My observations for the curious: Code: php spark migrate Will not perform any migration Code: php spark migrate --all Will perform the migrations from all namespaces but will designate the Group as default (should be picked up from within the migration file in my opinion) Code: php spark migrate -n Modules\\AbuseIpdb -g abuseipdb Will perform the migration as expected (only the relevant namespace) and assign the appropriate group. RE: AbuseIPDB Module - InsiteFX - 07-03-2025 Yes I have to agree with you on nuances of performing a migration on the command line. Maybe someone will get the time to look into it. |