-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Database Seeder not running in Modules Exception Error Looks like the path is wrong! #9381
Comments
I see that you created a seeder in a specific namespace and then tried to run the command: php spark db:seed BlogSeeder which will search for the seeder only in the php spark db:seed InsiteFX\Blog\Database\Seeds\BlogSeeder |
I agree. I also got an error, but the FQCN works. |
Seeder will not search in all namespaces for the file - this is by design. This could potentially cause problems when multiple seeder files have the same name. |
michalsn, I understand what you are saying, but why do the Migrations work in the namespace but the Seeder does not? I think that this is confusing the users. I answered 2 questions that were similar. Shouldn't the Seeder work just like the Migrations? Thank you |
Migrations runs all new migration files, but seeder runs only a specified seed file. |
@InsiteFX What do you mean? Calling Indeed, Seeder does not support additional parameters, but if you think they should - send a PR. Although I think allowing the calls like: php spark db:seed -n InsiteFX\Blog
// or
php spark db:seed -all may cause a lot of problems instead of helping users. As @kenjis mentioned, Seeders are not Migrations and they should be executed with caution because we have no history of which seeders have been called before. |
Yes. If migrations can be skipped, then Seeder will upload all its data again. |
Ok, here is a new one, I ran migrations for Shield and the Blog all tables created. I have tried the Seeder from InsiteFX\Blog and from the App folder and this is the error Says it cannot find the article table but yet it is there in phpMyAdmin Database is ci4_multi all Shield and Blog tables are there! ERROR: PS C:\laragon\www\ci4multi> php spark db:seed BlogSeeder CodeIgniter v4.5.6 Command Line Tool - Server Time: 2025-01-08 07:21:58 UTC-05:00 [CodeIgniter\Database\Exceptions\DatabaseException] Caused by: Caused by: Backtrace: 2 SYSTEMPATH\Database\BaseConnection.php:734 3 SYSTEMPATH\Database\BaseConnection.php:648 4 SYSTEMPATH\Database\BaseBuilder.php:2340 5 APPPATH\Database\Seeds\BlogSeeder.php:47 6 SYSTEMPATH\Database\Seeder.php:147 7 SYSTEMPATH\Commands\Database\Seed.php:79 8 SYSTEMPATH\CLI\Commands.php:70 9 SYSTEMPATH\CLI\Console.php:48 10 SYSTEMPATH\Boot.php:360 11 SYSTEMPATH\Boot.php:104 12 ROOTPATH\spark:84 PS C:\laragon\www\ci4multi> Same ERROR from both Seeders php spark db:seed InsiteFX\Blog\Database\Seeds\BlogSeeder php spark db:seed BlogSeeder This is a Windows 11 Pro System |
There may be an error due to Win 11. Check the paths in the database and in Seeder. Especially the slashes |
The seeder files were deleted from the folder that was not being used. There were no two seeders with the same name, I deleted them from the folder not being used. This use to work because I seeded the blog before using IncludeBeers seeder a few months ago, |
Please provide some more code - your migration and seeder, so we can try to reproduce the error. |
I apologize to the CodeIgniter Development Team. I had like 25 records in the BlogSeeder file and one of them was spelled wrong missing an s on the All is working now from App and Module Blog, so I' am closing the issue Just another stupid mistake. Thank you |
PHP Version
8.3
CodeIgniter4 Version
4.5.6
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
MySQL 8.0.30
What happened?
Looks like the path is wrong using / and \ slashes in the url
php spark db:seed BlogSeeder
PS C:\laragon\www\ci4multi> php spark db:seed BlogSeeder
CodeIgniter v4.5.6 Command Line Tool - Server Time: 2025-01-08 01:23:14 UTC-05:00
[InvalidArgumentException]
The specified seeder is not a valid file: C:\laragon\www\ci4multi\app\Database/Seeds/BlogSeeder.php
at SYSTEMPATH\Database\Seeder.php:132
Backtrace:
1 SYSTEMPATH\Commands\Database\Seed.php:79
CodeIgniter\Database\Seeder()->call('BlogSeeder')
2 SYSTEMPATH\CLI\Commands.php:70
CodeIgniter\Commands\Database\Seed()->run([])
3 SYSTEMPATH\CLI\Console.php:48
CodeIgniter\CLI\Commands()->run('db:seed', [...])
4 SYSTEMPATH\Boot.php:360
CodeIgniter\CLI\Console()->run()
5 SYSTEMPATH\Boot.php:104
CodeIgniter\Boot::runCommand(Object(CodeIgniter\CLI\Console))
6 ROOTPATH\spark:84
CodeIgniter\Boot::bootSpark(Object(Config\Paths))
PS C:\laragon\www\ci4multi>
Steps to Reproduce
Create a new Module Seeder file.
php spark make:seeder BlogSeeder --namespace InsiteFX\Blog
Expected Output
Create a module seeder file.
php spark make:seeder BlogSeeder --namespace InsiteFX\Blog
Anything else?
No response
The text was updated successfully, but these errors were encountered: