fix exception for project without status, fix character set in company table

This commit is contained in:
vladrigos 2020-08-04 11:16:14 +03:00
parent 8b3687cb81
commit fa731a80fe
2 changed files with 31 additions and 1 deletions

View File

@ -52,7 +52,7 @@ class Project extends \yii\db\ActiveRecord
public function rules()
{
return [
[['name'], 'required'],
[['name', 'status'], 'required'],
[['description'], 'string'],
[['created_at', 'updated_at'], 'safe'],
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],

View File

@ -0,0 +1,30 @@
<?php
use yii\db\Migration;
/**
* Class m200803_135837_add_table_options_to_company_table
*/
class m200803_135837_add_table_options_to_company_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
if ($this->db->driverName === 'mysql') {
$this->execute('ALTER TABLE company DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB');
}
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
if ($this->db->driverName === 'mysql') {
$this->execute('ALTER TABLE company DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ENGINE=InnoDB');
}
}
}