--- /dev/null
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `{{%sent_kogort}}`.
+ */
+class m241220_131428_create_sent_kogort_table extends Migration
+{
+ const TABLE_NAME = 'erp24.sent_kogort';
+ /**
+ * {@inheritdoc}
+ */
+ public function safeUp()
+ {
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+ if (!isset($tableSchema)) {
+ $this->createTable(self::TABLE_NAME, [
+ 'id' => $this->primaryKey(),
+ 'phone' => $this->string(15)->notNull()->comment('Телефон пользователя'),
+ 'kogort_date' => $this->date()->notNull()->comment('Дата когорты'),
+ 'kogort_unixtime' => $this->integer()->notNull()->comment('UNIX-время когорты'),
+ 'status' => $this->tinyInteger(1)->notNull()->defaultValue(1)->comment('Вхождение в когорту'),
+ 'contact' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('Контакт с клиентом'),
+ 'purchase' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('Покупка'),
+ 'created_at' => $this->dateTime()->notNull()->comment('Дата создания записи'),
+ ]);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+ if (isset($tableSchema)) {
+ $this->dropTable(self::TABLE_NAME);
+ }
+ }
+}
--- /dev/null
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+
+/**
+ * This is the model class for table "sent_kogort".
+ *
+ * @property int $id
+ * @property string $phone Телефон пользователя
+ * @property string $kogort_date Дата когорты
+ * @property int $kogort_unixtime UNIX-время когорты
+ * @property int $status Вхождение в когорту
+ * @property int $contact Контакт с клиентом
+ * @property int $purchase Покупка
+ * @property string $created_at Дата создания записи
+ */
+class SentKogort extends \yii\db\ActiveRecord
+{
+ /**
+ * {@inheritdoc}
+ */
+ public static function tableName()
+ {
+ return 'sent_kogort';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function rules()
+ {
+ return [
+ [['phone', 'kogort_date', 'kogort_unixtime', 'created_at'], 'required'],
+ [['kogort_date', 'created_at'], 'safe'],
+ [['kogort_unixtime', 'status', 'contact', 'purchase'], 'default', 'value' => null],
+ [['kogort_unixtime', 'status', 'contact', 'purchase'], 'integer'],
+ [['phone'], 'string', 'max' => 15],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id' => 'ID',
+ 'phone' => 'Телефон пользователя',
+ 'kogort_date' => 'Дата когорты',
+ 'kogort_unixtime' => 'UNIX-время когорты',
+ 'status' => 'Вхождение в когорту',
+ 'contact' => 'Контакт с клиентом',
+ 'purchase' => 'Покупка',
+ 'created_at' => 'Дата создания записи',
+ ];
+ }
+}