Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii 2 migrations for test database

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.

like image 482
Mr Peach Avatar asked Aug 14 '14 10:08

Mr Peach


People also ask

How do I run a specific migration in yii2?

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"

What is migration in yii?

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.


1 Answers

Just using yii_test migrate for Yii2.

like image 141
chariothy Avatar answered Sep 21 '22 17:09

chariothy