yii2-gii: The table does not exist: uacademy_persona. Model generator throws an error.

What steps will reproduce the problem?

I have created a model for the Persona use (an extended version of the profile) with a more complicated structure of data. I have described a model according to insolita/yii2-migration-generator@~3.1:

<?php

/**
 * Model class for Persona "uacademy_persona"
 */
namespace yaro\humhub\modules\UAcademy\models;

use humhub\components\ActiveRecord;
use humhub\modules\user\authclient\AuthClientHelpers;
use Yii;

/**
 * Model class for Persona "uacademy_persona"
 *
 * @property integer $id                @column pk|comment("Id")
 * @property integer $user_id           @column integer()|notNull
 * @property string  $name_first        @column string(60)|null
 * @property string  $name_last         @column string(60)|null
 * @property string  $name_parent       @column string(60)|null
 * @property string  $description       @column string(160)|null
 * @property string  $text              @column text(9000)|null
 * @property string  $rank_academic     @column string(60)|null
 * @property string  $rank_science      @column string(60)|null
 * @property string  $birth_place       @column string(60)|null
 * @property string  $birth_date        @column datetime()|null
 * @property string  $science_interests @column object()|null
 * @property array   $degrees           @column object()|null
 * @property array   $publications      @column object()|null
 * @property array   $activities        @column object()|null
 * @property array   $member_of         @column object()|null
 * @property array   $awards            @column object()|null
 * @property array   $sources           @column object()|null
 * @property array   $contacts          @column object()|null
 * @property string  $source_link       @column object()|null
 * @property \humhub\modules\user\models\User $user
 */
class Persona extends ActiveRecord
{
    /**
     * @since 1.3.2
     */
    const SCENARIO_EDIT_ADMIN = 'editAdmin';
    const SCENARIO_REGISTRATION = 'registration';
    const SCENARIO_EDIT_PROFILE = 'editProfile';

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'uacademy_persona';
    }
// ...
}

I tried to run a table generator and it throws me an error: Table does not exist. Ok. I have created a table in the database with MariaDB commands in the MariaDB client, so what I have in the database:

MariaDB [intranet]> describe uacademy_persona;
+-------+---------+------+-----+---------+----------------+
| Field | Type    | Null | Key | Default | Extra          |
+-------+---------+------+-----+---------+----------------+
| id    | int(11) | NO   | PRI | NULL    | auto_increment |
+-------+---------+------+-----+---------+----------------+
1 row in set (0.004 sec)

But I had the same error again. So I have run clear cache command in the console:

php yii cache cache/flush-all  
The following caches were found in the system:

	* cache (yii\caching\FileCache)

yii cache cache/flush-schema
The following caches were found in the system:

	* cache (yii\caching\FileCache)php 

But this did not help either.

What’s expected?

Migration file was created to run the migration as it should work.

What do you get instead?

An error “The table does not exist: uacademy_persona”

Additional info

Q A
Yii version 2.0.47
PHP version 8.1.11
Database version 10.8.3-MariaDB Homebrew
Operating system Darwin Kernel Version 21.5.0

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

We are talking here about several things at the same time so it would be nice to extract a single thing into a separate issue if you find something not working properly. As for the builder documentation I’m afraid I cannot help you with that since Gii docs are quite minimal, it would be nice to have it completed.

By running some SQL query using the app. Anyway, interesting, maybe indeed DB schema cache is the reason, do you have it switched on?