]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/blob
0c4cdff540253dc414c7b0697ca5eebf866acab6
[erp24_rep/yii-erp24/.git] /
1 <?php
2
3 use yii\db\Migration;
4
5 class m250718_093101_add_cancelled_order_source_date_fields_to_marketplace_orders_table extends Migration
6 {
7     const TABLE_NAME = 'erp24.marketplace_orders';
8     /**
9      * {@inheritdoc}
10      */
11     public function safeUp()
12     {
13         $table = $this->db->schema->getTableSchema(self::TABLE_NAME);
14         if ($table === null) {
15             return;
16         }
17
18         if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('cancelled_order_source')) {
19             $this->addColumn(
20                 self::TABLE_NAME,
21                 'cancelled_order_source',
22                 $this->string()->null()->comment('Источник отмененного заказа')
23             );
24         }
25         if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('cancelled_order_date')) {
26             $this->addColumn(
27                 self::TABLE_NAME,
28                 'cancelled_order_date',
29                 $this->timestamp()->null()->comment('Время отправки отмененного заказа в 1С')
30             );
31         }
32     }
33
34     /**
35      * {@inheritdoc}
36      */
37     public function safeDown()
38     {
39         if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('cancelled_order_source')) {
40             $this->dropColumn(self::TABLE_NAME, 'cancelled_order_source');
41         }
42         if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('cancelled_order_date')) {
43             $this->dropColumn(self::TABLE_NAME, 'cancelled_order_date');
44         }
45     }
46     
47     /*
48     // Use up()/down() to run migration code without a transaction.
49     public function up()
50     {
51
52     }
53
54     public function down()
55     {
56         echo "m250718_093101_add_cancelled_order_source_date_fields_to_marketplace_orders_table cannot be reverted.\n";
57
58         return false;
59     }
60     */
61 }