yii-starter-kit / yii2-starter-kit

Yii2 Starter Kit
http://yii2-starter-kit.terentev.net
Other
1.42k stars 648 forks source link

Migration will failed for MYSQL version 8.0.21 or higher #766

Closed salleh closed 3 years ago

salleh commented 3 years ago

When running initial installation php console/yii app/setup

the migration script m150725_192740_seed_data will fail with error:

> insert into {{%user_profile}} ...Exception: Undefined index: constraint_name.

The following addition to db config should prevent this error:

 'db' => [
            'attributes' => [PDO::ATTR_CASE => PDO::CASE_LOWER],
        ],

in this case, I changed the file @root_folder/common/config/base.php to have the following db configuration:

'db' => [
            'class' => yii\db\Connection::class,
            'dsn' => env('DB_DSN'),
            'username' => env('DB_USERNAME'),
            'password' => env('DB_PASSWORD'),
            'tablePrefix' => env('DB_TABLE_PREFIX'),
            'charset' => env('DB_CHARSET', 'utf8'),
            'enableSchemaCache' => YII_ENV_PROD,
            'attributes' => [PDO::ATTR_CASE => PDO::CASE_LOWER],
        ],
rivieiraa commented 3 years ago

Run composer update before running migrations

XzAeRo commented 3 years ago

I could not replicate this issue using MySQL 8.0.22. Are you sure you are up to date with the package dependencies from composer?