]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление миграции и таблицы
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 10 Jan 2025 08:42:04 +0000 (11:42 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 10 Jan 2025 08:42:04 +0000 (11:42 +0300)
erp24/migrations/m250110_074741_create_users_telegram_message_table.php [new file with mode: 0644]
erp24/records/SentKogort.php

diff --git a/erp24/migrations/m250110_074741_create_users_telegram_message_table.php b/erp24/migrations/m250110_074741_create_users_telegram_message_table.php
new file mode 100644 (file)
index 0000000..c90ff9a
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `{{%users_telegram_message}}`.
+ */
+class m250110_074741_create_users_telegram_message_table extends Migration
+{
+    const TABLE_NAME = 'erp24.users_telegram_message';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        if (!isset($tableSchema)) {
+            $this->createTable(self::TABLE_NAME, [
+                'id' => $this->bigPrimaryKey()->comment('ID'),
+                'chat_id' => $this->string()->notNull()->comment('Chat ID'),
+                'phone' => $this->string()->notNull()->comment('Телефон'),
+                'message' => $this->string()->notNull()->comment('Текст сообщения в Телеграм'),
+                'kogort_date' => $this->date()->notNull()->comment('Дата когорты'),
+                'target_date' => $this->date()->notNull()->comment('Целевая дата'),
+                'type' => $this->integer()->notNull()->defaultValue(1)
+                    ->comment('Номер рассылки: 1- первая, 2 - вторая'),
+                'created_at' => $this->dateTime()->notNull()->defaultExpression('CURRENT_TIMESTAMP')
+                    ->comment('Дата создания записи'),
+            ]);
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+        if (isset($tableSchema)) {
+            $this->dropTable(self::TABLE_NAME);
+        }
+    }
+}
index 6f2a925807ae27ca52da33bc91c5ffaba01572d5..1c05074b0620764447fe791df7fda8916e5472f3 100644 (file)
@@ -27,9 +27,9 @@ class SentKogort extends \yii\db\ActiveRecord
     ];
 
     public const STATUSES = [
-      'created' => 1,
-        'first' => 2,
-        'second' => 3,
+      'created' => 1, // создана запись в когорте
+        'first' => 2, // отправлено первое сообщение в чатбот на номер в когорте
+        'second' => 3, // отправлено второе сообщение на номер в когорте
     ];
     /**
      * {@inheritdoc}