From 3376ee8bc25fd06383fcbe3dffbf2da004ab7b0c Mon Sep 17 00:00:00 2001 From: fomichev Date: Wed, 25 Dec 2024 15:49:36 +0300 Subject: [PATCH] =?utf8?q?=D0=A2=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B0=20?= =?utf8?q?=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=87=D0=B0?= =?utf8?q?=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ...column_telegram_chat_id_to_users_table.php | 46 -------------- ...48_create_users_telegram_chat_id_table.php | 60 +++++++++++++++++++ 2 files changed, 60 insertions(+), 46 deletions(-) delete mode 100644 erp24/migrations/m241224_140248_add_column_telegram_chat_id_to_users_table.php create mode 100644 erp24/migrations/m241224_140248_create_users_telegram_chat_id_table.php diff --git a/erp24/migrations/m241224_140248_add_column_telegram_chat_id_to_users_table.php b/erp24/migrations/m241224_140248_add_column_telegram_chat_id_to_users_table.php deleted file mode 100644 index 322e5e6a..00000000 --- a/erp24/migrations/m241224_140248_add_column_telegram_chat_id_to_users_table.php +++ /dev/null @@ -1,46 +0,0 @@ -db->getTableSchema(self::TABLE_NAME, true)->getColumn(self::COLUMN_NAME)) { - $this->addColumn(self::TABLE_NAME, self::COLUMN_NAME, $this->string()->comment('Telegram Chat ID')); - } - } - - /** - * {@inheritdoc} - */ - public function safeDown() - { - if ($this->db->getTableSchema(self::TABLE_NAME, true)->getColumn(self::COLUMN_NAME)) { - $this->dropColumn(self::TABLE_NAME, self::COLUMN_NAME); - } - } - - /* - // Use up()/down() to run migration code without a transaction. - public function up() - { - - } - - public function down() - { - echo "m241224_140248_add_telegram_chat_id_to_users_table cannot be reverted.\n"; - - return false; - } - */ -} diff --git a/erp24/migrations/m241224_140248_create_users_telegram_chat_id_table.php b/erp24/migrations/m241224_140248_create_users_telegram_chat_id_table.php new file mode 100644 index 00000000..53217ec1 --- /dev/null +++ b/erp24/migrations/m241224_140248_create_users_telegram_chat_id_table.php @@ -0,0 +1,60 @@ +db->getTableSchema(self::TABLE_NAME); + + if (!isset($tableSchema)) { + $this->createTable(self::TABLE_NAME, [ + 'chat_id' => $this->string()->notNull()->comment('Chat ID'), + 'phone' => $this->string()->null()->comment('Телефон'), + 'username' => $this->string()->null()->comment('Имя пользователя в Телеграм'), + 'first_name' => $this->string()->null()->comment('Имя пользователя'), + 'is_blocked' => $this->integer(1)->notNull()->defaultValue(0)->comment( + 'Заблокирован: 0 - нет, 1 - да' + ), + 'is_registered' => $this->integer(1)->notNull()->defaultValue(0)->comment( + 'Зарегистрирован: 0 - нет, 1 - да' + ), + ]); + } + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $tableSchema = $this->db->getTableSchema(self::TABLE_NAME); + if (isset($tableSchema)) { + $this->dropTable(self::TABLE_NAME); + } + } + + /* + // Use up()/down() to run migration code without a transaction. + public function up() + { + + } + + public function down() + { + echo "m241224_140248_add_telegram_chat_id_to_users_table cannot be reverted.\n"; + + return false; + } + */ +} -- 2.39.5