Welcome Guest, Not a member yet? Register   Sign In
Migration group issue
#1

(This post was last modified: 06-22-2019, 12:52 AM by eincandela.)

Hello,

i'm trying to apply my migrations to my test database by using the -g option for groups

php spark migrate:latest -g tests

but the command still try to target my main database (db.local) AND my test database (db.test) at the same time.

My .env database setup is

database.default.database = db.local
database.tests.database = db.test

is that a bug or am i doing something wrong?

Thank you for any help
Reply
#2

Well your database is db.test and your using -g tests should it not be -g test?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(06-22-2019, 04:31 AM)InsiteFX Wrote: Well your database is db.test and your using -g tests should it not be -g test?

Thanks for your comment but in fact, db.test is the name of the database itself. The name of the group is the middle part of

database.tests.database = db.test

like it is for default group

database.default.database = db.local

but i tried it anyway Tongue doesn't work
Reply
#4

Hmm that's odd. Can you try it with `-all` and see if it has the same behavior? Also try it from a non-CLI context:
```
$runner = Services::migrations();
$result = $runner->latest(null, 'tests');
var_dump($result);
```
Reply
#5

(This post was last modified: 06-22-2019, 10:10 AM by eincandela.)

:/ Doesn't work either, command line or scripts. It it still trying to target my main db and never the "tests" one. I also tried  to setup db config in the according file in App\Config with no success. The groups seems totay ignored.

ps: Thanks your for the code example  as i was going to need it..by the way, do you have any idea how to use the rollback() method from a script ? it seems not present in the migrations service.
Reply
#6

Okay I recommend you submit a bug report on GitHub and someone will take a look at it.

For rollback you can just call `version` with "0": $runner->version(0); - though I should note that migrations are being reworked right now so I'd recommend against writing a lot of code around the current implementation in case things change (https://github.com/codeigniter4/CodeIgniter4/pull/2065).
Reply
#7

(06-22-2019, 06:35 PM)MGatner Wrote: Okay I recommend you submit a bug report on GitHub and someone will take a look at it.

Ok. I will.

For rollback you can just call `version` with "0": $runner->version(0); - though I should note that migrations are being reworked right now so I'd recommend against writing a lot of code around the current implementation in case things change (https://github.com/codeigniter4/CodeIgniter4/pull/2065).

thank you very much Smile
Reply
#8

I guess i have found the problem: In the migrationRunner, the database is selected in the constructor only. The setGroup method is called in latest(), it can change the group but the database is never reconnected.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB