From fa731a80fe65c6fa4352b69cf34b564690683204 Mon Sep 17 00:00:00 2001 From: vladrigos Date: Tue, 4 Aug 2020 11:16:14 +0300 Subject: [PATCH] fix exception for project without status, fix character set in company table --- common/models/Project.php | 2 +- ...837_add_table_options_to_company_table.php | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 console/migrations/m200803_135837_add_table_options_to_company_table.php diff --git a/common/models/Project.php b/common/models/Project.php index 1f471de..9ec01d3 100755 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -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']], diff --git a/console/migrations/m200803_135837_add_table_options_to_company_table.php b/console/migrations/m200803_135837_add_table_options_to_company_table.php new file mode 100644 index 0000000..630bdb3 --- /dev/null +++ b/console/migrations/m200803_135837_add_table_options_to_company_table.php @@ -0,0 +1,30 @@ +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'); + } + } +} +