From: fomichev Date: Wed, 25 Dec 2024 12:49:36 +0000 (+0300) Subject: Таблица хранения чатов X-Git-Tag: 1.7~94^2~41 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=3376ee8bc25fd06383fcbe3dffbf2da004ab7b0c;p=erp24_rep%2Fyii-erp24%2F.git Таблица хранения чатов --- 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; + } + */ +}