Gii Model generator wont let me to create a Model.(Throws Table 'authors' does not exist)

173 views Asked by At

I created a migration for the authors table.

public function up()
    {
        $this->createTable('authors', [
            'id' => $this->primaryKey(),
            'name' => $this->string()->notNull()
        ]);
    }

    public function down()
    {
        $this->dropTable('authors');
    }

After migrating a table,I wanted to make a model for the migration. so Tried creating a model using the gii and this is what i got. enter image description here

The table authors has already been created by the migration,but the gii model generator still says Table 'authors' does not exist. Is there anything else that i am missing?

This is my db.php file

<?php

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=myFirstYii',
    'username' => 'root',
    'password' => '',
    'charset' => 'utf8',

    // Schema cache options (for production environment)
    //'enableSchemaCache' => true,
    //'schemaCacheDuration' => 60,
    //'schemaCache' => 'cache',
];
0

There are 0 answers