]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-5 Доработать фактический план по сотрудникам
authormarina <m.zozirova@gmail.com>
Thu, 13 Jun 2024 07:50:53 +0000 (10:50 +0300)
committermarina <m.zozirova@gmail.com>
Thu, 13 Jun 2024 07:50:53 +0000 (10:50 +0300)
erp24/migrations/m240603_082541_create_new_fact_plan_table.php

index e9cabca49663ffcc9ba775f260cfe0f3bc7e8cb2..2ab233dbd3931819aa47ebbe5d9deb664bdb88c0 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 use yii\db\Migration;
+use yii_app\records\TimetableFact;
 
 /**
  * Handles the creation of table `{{%new_fact_plan}}`.
@@ -12,38 +13,40 @@ class m240603_082541_create_new_fact_plan_table extends Migration
      */
     public function safeUp()
     {
-        $this->createTable('{{%erp24.timetable_fact}}', [
-            'id' => $this->primaryKey(),
-            'admin_id' => $this->integer()->comment('ID сотрудника'),
-            'store_id' => $this->integer()->comment('ID магазина'),
-            'admin_group_id' => $this->integer()->comment('ID должности'),
-            'd_id' => $this->integer()->comment('в какой должности работал на смене'),
-            'date_shift' => $this->date()->comment('дата смены'),
-            'date_start' => $this->date()->comment('дата время открытия смены'),
-            'date_end' => $this->date()->comment('дата время закрытия смены'),
-            'is_opening' => $this->boolean()->comment('на открытие смены'),
-            'is_close' => $this->boolean()->comment('на закрытие смены'),
-            'tabel' => $this->integer()->comment('табель'),
-            'plan_id' => $this->integer()->comment('ID табеля если смена поставлена'),
-            'shift_id' => $this->integer()->comment('тип смены'),
-            'admin_id_add' => $this->integer()->comment('ID поставившего смену'),
-            'time_start' => $this->time()->comment('время начала работы по графику'),
-            'time_end' => $this->time()->comment('время окончания работы по графику'),
-            'work_time' => $this->float()->comment('рабочее время'),
-            'price_hour' => $this->float()->comment('часовая ставка'),
-            'salary_shift' => $this->integer()->comment('оплата за смену'),
-            'slot_type_id' => $this->integer()->comment('тип занятности'),
-            'comment' => $this->text()->comment('комментарий'),
-            'date_add' => $this->timestamp()->comment('дата постановки смены'),
-            'status' => $this->integer()->comment('статус смены'),
-        ]);
+        if ($this->db->getTableSchema(TimetableFact::tableName()) !== null) {
+            $this->createTable('{{%erp24.timetable_fact}}', [
+                'id' => $this->primaryKey(),
+                'admin_id' => $this->integer()->comment('ID сотрудника'),
+                'store_id' => $this->integer()->comment('ID магазина'),
+                'admin_group_id' => $this->integer()->comment('ID должности'),
+                'd_id' => $this->integer()->comment('в какой должности работал на смене'),
+                'date_shift' => $this->date()->comment('дата смены'),
+                'date_start' => $this->date()->comment('дата время открытия смены'),
+                'date_end' => $this->date()->comment('дата время закрытия смены'),
+                'is_opening' => $this->boolean()->comment('на открытие смены'),
+                'is_close' => $this->boolean()->comment('на закрытие смены'),
+                'tabel' => $this->integer()->comment('табель'),
+                'plan_id' => $this->integer()->comment('ID табеля если смена поставлена'),
+                'shift_id' => $this->integer()->comment('тип смены'),
+                'admin_id_add' => $this->integer()->comment('ID поставившего смену'),
+                'time_start' => $this->time()->comment('время начала работы по графику'),
+                'time_end' => $this->time()->comment('время окончания работы по графику'),
+                'work_time' => $this->float()->comment('рабочее время'),
+                'price_hour' => $this->float()->comment('часовая ставка'),
+                'salary_shift' => $this->integer()->comment('оплата за смену'),
+                'slot_type_id' => $this->integer()->comment('тип занятности'),
+                'comment' => $this->text()->comment('комментарий'),
+                'date_add' => $this->timestamp()->comment('дата постановки смены'),
+                'status' => $this->integer()->comment('статус смены'),
+            ]);
 
-        $this->addForeignKey('fk_timetable_fact_to_admin', 'timetable_fact', 'admin_id', 'admin', 'id');
-        $this->addForeignKey('fk_timetable_fact_to_store', 'timetable_fact', 'store_id', 'store', 'id');
-        $this->addForeignKey('fk_timetable_fact_to_admin_group', 'timetable_fact', 'admin_group_id', 'admin_group', 'id');
-        $this->addForeignKey('fk_timetable_fact_to_admin_group_as_d', 'timetable_fact', 'd_id', 'admin_group', 'id');
-        $this->addForeignKey('fk_timetable_fact_to_plan', 'timetable_fact', 'plan_id', 'timetable', 'id');
-        $this->addForeignKey('fk_timetable_fact_to_admin_as_admin_id_add', 'timetable_fact', 'admin_id_add', 'admin', 'id');
+            $this->addForeignKey('fk_timetable_fact_to_admin', 'timetable_fact', 'admin_id', 'admin', 'id');
+            $this->addForeignKey('fk_timetable_fact_to_store', 'timetable_fact', 'store_id', 'store', 'id');
+            $this->addForeignKey('fk_timetable_fact_to_admin_group', 'timetable_fact', 'admin_group_id', 'admin_group', 'id');
+            $this->addForeignKey('fk_timetable_fact_to_admin_group_as_d', 'timetable_fact', 'd_id', 'admin_group', 'id');
+            $this->addForeignKey('fk_timetable_fact_to_plan', 'timetable_fact', 'plan_id', 'timetable', 'id');
+            $this->addForeignKey('fk_timetable_fact_to_admin_as_admin_id_add', 'timetable_fact', 'admin_id_add', 'admin', 'id');
+        }
     }
 
     /**