--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m240719_063451_create_table_motivation
+ */
+class m240719_063451_create_table_motivation extends Migration
+{
+ const TABLE_NAME = "erp24.motivation";
+ const TABLE_NAME2 = "erp24.motivation_value";
+ const TABLE_NAME3 = "erp24.motivation_value_group";
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $this->createTable(self::TABLE_NAME, [
+ 'id' => $this->primaryKey(),
+ 'store_id' => $this->integer()->notNull()->comment('ID магазина'),
+ 'year' => $this->integer()->notNull()->comment('Год'),
+ 'month' => $this->integer()->notNull()->comment('Месяц'),
+ 'updated_at' => $this->datetime()->notNull()->comment('Дата изменения записи'),
+ 'created_at' => $this->datetime()->notNull()->comment('Дата создания записи'),
+ ]);
+
+ $this->createTable(self::TABLE_NAME2, [
+ 'id' => $this->primaryKey(),
+ 'motivation_id' => $this->integer()->notNull()->comment('ID motivation'),
+ 'motivation_group_id' => $this->integer()->notNull()->comment('ID motivation'),
+ 'value_id' => $this->integer()->notNull()->comment('ID motivation'),
+ 'value_type' => $this->string(10)->notNull()->comment('тип значения'),
+ 'value_int' => $this->integer()->null()->comment('value int'),
+ 'value_float' => $this->float()->null()->comment('value float'),
+ 'value_string' => $this->string()->null()->comment('value string'),
+ ]);
+
+ $this->createTable(self::TABLE_NAME3, [
+ 'id' => $this->primaryKey(),
+ 'name' => $this->string(80)->notNull()->comment('Название'),
+ 'alias' => $this->string(80)->notNull()->comment('Алиас'),
+ ]);
+
+ $this->batchInsert(self::TABLE_NAME3, ['id', 'name', 'alias'], [
+ [1, 'Неделя 1', 'week1'],
+ [2, 'Неделя 2', 'week2'],
+ [3, 'Неделя 3', 'week3'],
+ [4, 'Неделя 4', 'week4'],
+ [5, 'Неделя 5', 'week5'],
+ [6, 'Факт', 'fact'],
+ [7, 'План', 'plan'],
+ [8, 'Корректировка', 'adjustment'],
+ ]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $this->dropTable(self::TABLE_NAME3);
+ $this->dropTable(self::TABLE_NAME2);
+ $this->dropTable(self::TABLE_NAME);
+ }
+}