0

I'm trying to configure a new Yii2 project to work only using Redis Active Record (http://www.yiiframework.com/doc-2.0/yii-redis-activerecord.html). Redis is not supported like a regular db.

My migration will setup the first user of the application. It's not trying to alter a database schema. Is it possible in Yii2? Or I'll have to configure, for example, an sqlite db that will do nothing?

There is nothing similar to it in the documentation. And any migration extends yii\db\Migration (that tries to configure a db during the init).

Any workaround?

toctoc (master)$ ./yii migrate/up

Returns:

Yii Migration Tool (based on Yii v2.0.6)

Exception 'ReflectionException' with message 'Class db does not exist'

in toctoc/vendor/yiisoft/yii2/di/Container.php:415

Stack trace:
#0 toctoc/vendor/yiisoft/yii2/di/Container.php(415): ReflectionClass->__construct('db')
#1 toctoc/vendor/yiisoft/yii2/di/Container.php(358): yii\di\Container->getDependencies('db')
#2 toctoc/vendor/yiisoft/yii2/di/Container.php(151): yii\di\Container->build('db', Array, Array)
#3 toctoc/vendor/yiisoft/yii2/di/Instance.php(154): yii\di\Container->get('db')
#4 toctoc/vendor/yiisoft/yii2/di/Instance.php(128): yii\di\Instance->get(NULL)
#5 toctoc/vendor/yiisoft/yii2/console/controllers/MigrateController.php(95): yii\di\Instance::ensure('db', 'yii\\db\\Connecti...')
#6 toctoc/vendor/yiisoft/yii2/base/Controller.php(149): yii\console\controllers\MigrateController->beforeAction(Object(yii\base\InlineAction))
#7 toctoc/vendor/yiisoft/yii2/console/Controller.php(91): yii\base\Controller->runAction('up', Array)
#8 toctoc/vendor/yiisoft/yii2/base/Module.php(455): yii\console\Controller->runAction('up', Array)
#9 toctoc/vendor/yiisoft/yii2/console/Application.php(167): yii\base\Module->runAction('migrate/up', Array)
#10 toctoc/vendor/yiisoft/yii2/console/Application.php(143): yii\console\Application->runAction('migrate/up', Array)
#11 toctoc/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#12 toctoc/yii(19): yii\base\Application->run()
#13 {main}
otaviofcs
  • 785
  • 2
  • 6
  • 16
  • To do migrate you need to set `db` in config file unless you overwrite MigrateController – Patryk Radziszewski Jan 22 '16 at 08:02
  • Hi @PatrykRadziszewski. I figured out the same. I'll try to patch and submit the code to Yii2 Meanwhile I'll use db. Thanks for your time – otaviofcs Jan 24 '16 at 12:40
  • To improve my last comment, MigrateController relies on migrateTable to see whenever the migration has already run (or not). I'll have to implement a different pattern for each NoSQL DB. For example, on a Redis DB I would choose a Set in order to store and retrieve the list. – otaviofcs Jan 24 '16 at 14:39

0 Answers0