protected function prepare()
    {
        $sqlMode = null;

        if (Yii::$app->db->schema instanceof \yii\db\mysql\Schema) {
            Yii::$app->db->createCommand('SET FOREIGN_KEY_CHECKS = 0;')->execute();
            Yii::$app->db->createCommand('SET UNIQUE_CHECKS = 0;')->execute();

            $sqlMode = Yii::$app->db->createCommand('SELECT @@SQL_MODE;')->queryScalar();
            Yii::$app->db->createCommand('SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";')->execute();
        }

        return $sqlMode;
    }