5

I am trying to use migrate command with yii2 basic template i have tried "yii migrate" and also "php yii migrate" but none of them are working. i also tried php init but it says "could not open input file: init".

  • windows 7 operating system –  Sep 11 '15 at 10:13
  • what path in cmd where to run command? – GAMITG Sep 11 '15 at 10:17
  • 3
    possible duplicate of [yii2 installation - migrate command not working](http://stackoverflow.com/questions/24531583/yii2-installation-migrate-command-not-working) – vishuB Sep 11 '15 at 10:20
  • I am using my path to my basic folder –  Sep 11 '15 at 10:29
  • `init` does not exists in basic template. And show what is the error you get (and everything that is required) otherwise your question may be closed for not being constructive. – ankitr Sep 11 '15 at 10:37
  • meanwhile read the documentation http://www.yiiframework.com/doc-2.0/guide-db-migrations.html – ankitr Sep 11 '15 at 10:44
  • **Yii2 basic** doesn't come with the start migration files as user migration files. You can import those files from **advanced template** and put inside a migration folder. – Thiago Augustus Oliveira Sep 11 '15 at 11:28

2 Answers2

8

Yii2 basic doesn't come with the start migration files as user migration files. You can import those files from advanced template and put inside a migration folder. After that and config your db you can run yii migrate.

  • 2
    thanks. That wasn't clear enough on documentation. Stuck on that for a little bit. – Alex Pogiba Nov 27 '15 at 07:42
  • Can you expand on this? What files do I need to import? Right now, my command line says that `migrate/create` isn't a command and plain old `migrate` says "Directory specified in migrationPath doesn't exist". I don't need the migration files necessarily, just the ability to create and execute new ones. – Ethan C Dec 29 '15 at 17:33
  • @EthanC I'll upgrade this answer soon as possible. :) – Thiago Augustus Oliveira Dec 29 '15 at 19:22
  • Thanks! While information on where to find the RBAC table migrations would be nice, the issue with `migrate/create` not recognized as a command (as well as all other sub commands) had something to do with Git Bash, as it works just fine in Windows CMD – Ethan C Dec 29 '15 at 19:59
0

The "controllerMap" configuration is typically used in the application bootstrap file (index.php for web applications or yii for console applications) to configure console controllers.

To configure console controllers using the "controllerMap" component, you need to modify your application bootstrap file (e.g., yii file for console applications). Here's an example of how to configure the "migrate" controller using the "controllerMap" component:

// yii (console application bootstrap file)

$config = require __DIR__ . '/config/console.php';

$config['controllerMap'] = [
    'migrate' => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationPath' => [
            '@app/migrations', // path to your custom migrations directory
            '@yii/rbac/migrations', // path to RBAC migrations (optional)
        ],
    ],
];

$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);
Json
  • 1
  • 1
  • Please note that the use of GPT/AI tools continues to be banned here. This answer appears likely to have been written (entirely or partially) by AI. If you used an AI tool to assist in this answer, I would encourage you to delete it. For readers of this answer, please validate the answer carefully and comment with any errors. Users who post low-quality information from AI may be suspended, and the moderation team could use your help identifying issues in the post (if any). – NotTheDr01ds Jun 01 '23 at 13:12