-
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
Fix spark migrate
issue with -g option
#7846
Conversation
Thank you for sending PR! You must sign all commits with a valid GPG key. |
spark migrate
issue with -g option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good! Please address the merge blockers.
b637bbc
to
13a870c
Compare
Sorry team, I was on vacation, I've removed the unsigned commit. |
4ce8f5d
to
3531d7b
Compare
Ok, sorry, email author problem, this one is good. |
@filoboss Thank you for signing.
Why there's no default database configured? Should it fail if you don't have the default database? |
Coding style check failed. Fix it. |
If there is no default group in $ php spark migrate -g test1
CodeIgniter v4.3.7 Command Line Tool - Server Time: 2023-09-04 02:08:22 UTC+00:00
[InvalidArgumentException]
default is not a valid database connection group.
at SYSTEMPATH/Database/Config.php:69
Backtrace:
1 SYSTEMPATH/Common.php:362
CodeIgniter\Database\Config::connect('default', true)
2 SYSTEMPATH/Database/MigrationRunner.php:151
db_connect(null)
3 SYSTEMPATH/Config/Services.php:415
CodeIgniter\Database\MigrationRunner()->__construct(null, null)
4 SYSTEMPATH/Config/BaseService.php:252
CodeIgniter\Config\Services::migrations(Object(Config\Migrations), null, false)
5 SYSTEMPATH/Config/BaseService.php:193
CodeIgniter\Config\BaseService::__callStatic('migrations', [...])
6 SYSTEMPATH/Config/Services.php:410
CodeIgniter\Config\BaseService::getSharedInstance('migrations', null, null)
7 SYSTEMPATH/Config/BaseService.php:252
CodeIgniter\Config\Services::migrations()
8 SYSTEMPATH/Commands/Database/Migrate.php:69
CodeIgniter\Config\BaseService::__callStatic('migrations', [])
9 SYSTEMPATH/CLI/Commands.php:65
CodeIgniter\Commands\Database\Migrate()->run([...])
10 SYSTEMPATH/CLI/Console.php:37
CodeIgniter\CLI\Commands()->run('migrate', [...])
11 ROOTPATH/spark:97
CodeIgniter\CLI\Console()->run() |
I'm sure there is a bug round the |
We have update the description for |
Hi Guys, I run into a this problem as well. I have multiple database connections defined. The default is a read-only DB. For me the solution was to update the Now, i'm not sure if this is the right was to do this or if there are any other places to update, but as far as i can tell there is no other place besides the constructor in MigrationRunner where the database connection is set or where we allow to overwrite the db connection. |
@qury Your configuration is not supported by the CI4 DB migration. So you need to customize the migration for yourself. |
Description
Supersedes #7845
When performing a spark migrate with the -g option to use a different DBgroup other than the default, and when there's no default database configured, the migration fails. This is because
$this->ensureTable()
is executed before$this->setGroup($group)
. I've simply moved$this->ensureTable()
to execute after setting the group.Checklist: