-
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
php spark migrate, migrating table to wrong database group #5087
Comments
Hi and thanks for the bug report. Please give us a few more time to debug this issue (as we're just busy at work 😅). Anyway, I want to clarify your example migrations table (which I assume is generated by From that I assume it is working correctly, unless I am missing something here. Thanks. |
Yes, the tables migrated to the default database group, geonode_data. After executing And I check geonode_data database, all of my table that I needed in there. When I open migrations table, in group column, its filled with api_mobile. It's okay, I understand. For now I just need to change the database name from geonode_data to api_mobile in the default database group, and do the migrations. After the migration is done, I revert the database name. But I think this bug need to be fixed in the future.. Thanks... |
Hi @renmura ! Thanks for the thorough explanation. I think I get where the problem is, but it needs writing some testing. Can you check this for me if this "fix" will work?
- $this->ensureTable();
-
if ($group !== null) {
$this->groupFilter = $group;
$this->setGroup($group);
}
+
+ $this->ensureTable();
- $forge = Database::forge($this->db);
+ $forge = Database::forge($this->group ?: null); Save everything then re-run |
I can't reproduce. Create a migration file: <?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateCiSessionsTable extends Migration
{
protected $DBGroup = 'tests';
...
} $ php spark migrate:status
CodeIgniter v4.1.5 Command Line Tool - Server Time: 2021-11-10 20:59:02 UTC-06:00
+-----------+-------------------+-----------------------+-------+-------------+-------+
| Namespace | Version | Filename | Group | Migrated On | Batch |
+-----------+-------------------+-----------------------+-------+-------------+-------+
| App | 2021-11-11-022829 | CreateCiSessionsTable | --- | --- | --- |
+-----------+-------------------+-----------------------+-------+-------------+-------+ ↑ Not migrated yet. $ php spark migrate
CodeIgniter v4.1.5 Command Line Tool - Server Time: 2021-11-10 20:59:36 UTC-06:00
Running all new migrations...
Done migrations. ↑ $ php spark migrate -g tests
CodeIgniter v4.1.5 Command Line Tool - Server Time: 2021-11-10 21:04:03 UTC-06:00
Running all new migrations...
Running: (App) 2021-11-11-022829_App\Database\Migrations\CreateCiSessionsTable
Done migrations. ↑ Migrated. $ php spark migrate:status
CodeIgniter v4.1.5 Command Line Tool - Server Time: 2021-11-10 21:04:07 UTC-06:00
+-----------+-------------------+-----------------------+-------+---------------------+-------+
| Namespace | Version | Filename | Group | Migrated On | Batch |
+-----------+-------------------+-----------------------+-------+---------------------+-------+
| App | 2021-11-11-022829 | CreateCiSessionsTable | tests | 2021-11-10 21:04:03 | 1 |
+-----------+-------------------+-----------------------+-------+---------------------+-------+
|
No feedback received. Closing.. |
I'm facing this issue in the last few days. I have 3 databases to connect with. Well actually I just need to connect to 1 database since my task is on that 1 database. But, my other team members need to connect to other database, so we configured 3 database connections.
Note : the database I'm working on is api_mobile
A week ago, I created some migration files to migrate. At that time, I only made one database configuration. And executing
php spark migrate
has no problems.Several days later, we (team members) merging our work, so we created 3 database connections.
When I execute
php spark migrate -g api_mobile
(hoping my new migration file is creating table into api_mobile), all of the migration files that I have created is migrating tables into wrong database (migrated to default group).My laptop setup is:
Apache 2.4.48
PHP 8.0.9
PostgreSQL 13.3
My CLI response:
My migrations table (created by CI 4, and yes in the wrong database):
My Database.php file is:
My .env file is:
One of my migrations file:
Here's how to reproduce the error:
php spark migrate -g api_mobile
hoping that will only migrate api_mobile groupThank you for your times.. 😄
The text was updated successfully, but these errors were encountered: