I'm failing to see a clear way to do this, although I can see it being reiterated multiple times in the documentation, specifically:
Use yii migrate tool to upgrade your test database to the latest version;
found in http://www.yiiframework.com/doc-2.0/guide-test-fixture.html#summary (just to give an example)
What happens is that no matter how I configure the _console.php
and _config.php
within my tests/unit
folder, if I run the migration tool is picking up the main app db:
$ cd tests/unit
$ ../../yii migrate/up
Yii Migration Tool (based on Yii v2.0.0-dev)
No new migration found. Your system is up-to-date.
And yes, the test database is correctly configured (running tests will throw an error saying there are no tables). I can obviously create the db structure myself, but this is all about getting this feature work as it should.
I'm currently using the Basic app installed via composer.
To run specific migration, you can mark(skip) migrations upto just before one you want run. You can mark migration by using one of following command: Using timestamp to specify the migration yii migrate/mark 150101_185401. Using a string that can be parsed by strtotime() yii migrate/mark "2015-01-01 18:54:01"
Because a database structure change often requires some source code changes, Yii supports the so-called database migration feature that allows you to keep track of database changes in terms of database migrations which are version-controlled together with the source code.
Just using yii_test migrate
for Yii2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With