From daca40f64e84b035ade6f1d66e21ccc824877453 Mon Sep 17 00:00:00 2001 From: fomichev Date: Tue, 4 Feb 2025 10:03:06 +0300 Subject: [PATCH] =?utf8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=8F=20bonus=5Flevel=20=D0=B2?= =?utf8?q?=20Users?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ..._add_column_bonus_level_to_users_table.php | 58 +++++++++++++++++++ erp24/records/Users.php | 6 +- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 erp24/migrations/m250204_065535_add_column_bonus_level_to_users_table.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 index 00000000..36882c54 --- /dev/null +++ b/erp24/migrations/m250204_065535_add_column_bonus_level_to_users_table.php @@ -0,0 +1,58 @@ +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; + } + */ +} diff --git a/erp24/records/Users.php b/erp24/records/Users.php index c36834be..797b4f59 100755 --- a/erp24/records/Users.php +++ b/erp24/records/Users.php @@ -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' ]; } -- 2.39.5