<?php
use yii\db\Migration;
+use yii_app\records\TimetableFact;
/**
* Handles the creation of table `{{%new_fact_plan}}`.
*/
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');
+ }
}
/**