added history of changes

This commit is contained in:
vladrigos
2020-08-04 10:47:53 +03:00
parent 38069c57d4
commit 812bb2b23a
7 changed files with 186 additions and 36 deletions

View File

@ -0,0 +1,40 @@
<?php
use yii\db\Migration;
/**
* Handles the creation of table `{{%change_history}}`.
*/
class m200729_104128_create_change_history_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%change_history}}', [
'id' => $this->primaryKey(),
'type' => $this->string(255),
'type_id' => $this->integer(),
'field_name' => $this->string(255),
'label' => $this->string(255),
'old_value' => $this->string(255),
'new_value' => $this->string(255),
'created_at' => $this->dateTime(),
], $tableOptions);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('{{%change_history}}');
}
}