]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление поля bonus_level в Users
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 4 Feb 2025 07:03:06 +0000 (10:03 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 4 Feb 2025 07:03:06 +0000 (10:03 +0300)
erp24/migrations/m250204_065535_add_column_bonus_level_to_users_table.php [new file with mode: 0644]
erp24/records/Users.php

diff --git a/erp24/migrations/m250204_065535_add_column_bonus_level_to_users_table.php b/erp24/migrations/m250204_065535_add_column_bonus_level_to_users_table.php
new file mode 100644 (file)
index 0000000..36882c5
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m250204_065535_add_column_bonus_level_to_users_table
+ */
+class m250204_065535_add_column_bonus_level_to_users_table extends Migration
+{
+    const TABLE_NAME  = 'erp24.users';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME) === null) {
+            return;
+        }
+
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME)->getColumn('bonus_level') === null) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'bonus_level',
+                $this->string()->null()->comment('Уровань клиента в БС'),
+            );
+        }
+
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME) === null) {
+            return;
+        }
+
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME)->getColumn('bonus_level') !== null) {
+            $this->dropColumn(self::TABLE_NAME, 'bonus_level');
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m250204_065535_add_column_bonus_level_to_users_table cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}
index c36834bee53f1e1b483ddf454e204f6ce8d7c82e..797b4f5940b45ac67882dfdf005f4825e8dead65 100755 (executable)
@@ -67,6 +67,7 @@ use yii\helpers\BaseConsole;
  * @property int $events Импортированы ли события
  * @property string|null $first_minus_balance
  * @property string $info
+ * @property string|null $bonus_level Уровань клиента в БС
  */
 class Users extends \yii\db\ActiveRecord
 {
@@ -182,7 +183,7 @@ class Users extends \yii\db\ActiveRecord
                     'store_id',
                     'first_minus_balance',
                     'telegram_unsubscribed_at',
-
+                    'bonus_level',
                 ],
                 'safe'
             ],
@@ -217,7 +218,7 @@ class Users extends \yii\db\ActiveRecord
             [['comment', 'sale_store'], 'string', 'max' => 200],
             [['email'], 'string', 'max' => 70],
             [['phone_old'], 'string', 'max' => 250],
-            [['card', 'check_id'], 'string', 'max' => 35],
+            [['bonus_level', 'card', 'check_id'], 'string', 'max' => 35],
             [['password', 'keycode', 'seller_id'], 'string', 'max' => 36],
             [['email_true', 'phone_true'], 'string', 'max' => 15],
             [['check_id_forgot', 'sid_forgot'], 'string', 'max' => 45],
@@ -286,6 +287,7 @@ class Users extends \yii\db\ActiveRecord
             'black_list' => 'Black List',
             'events' => 'Events',
             'telegram_unsubscribed_at' => 'Telegram Unsubscribed At',
+            'bonus_level' => 'Bonus Level'
             ];
     }