]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Миграция
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 2 Oct 2025 11:46:41 +0000 (14:46 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 2 Oct 2025 11:46:41 +0000 (14:46 +0300)
erp24/migrations/m251002_140000_add_is_feed_active_to_matrix_erp_table.php [new file with mode: 0644]
erp24/records/MatrixErp.php

diff --git a/erp24/migrations/m251002_140000_add_is_feed_active_to_matrix_erp_table.php b/erp24/migrations/m251002_140000_add_is_feed_active_to_matrix_erp_table.php
new file mode 100644 (file)
index 0000000..947b290
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Добавляет поле is_feed_active в таблицу matrix_erp
+ */
+class m251002_140000_add_is_feed_active_to_matrix_erp_table extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    const TABLE_NAME = 'erp24.matrix_erp';
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        if (isset($tableSchema) && !isset($tableSchema->columns['is_feed_active'])) {
+            $this->addColumn(self::TABLE_NAME, 'is_feed_active', $this->tinyInteger()->defaultValue(0)->comment('Флаг помечающий что эта запись попадет в фид товаров'));
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+
+        if (isset($tableSchema) && isset($tableSchema->columns['is_feed_active'])) {
+            $this->dropColumn(self::TABLE_NAME, 'is_feed_active');
+        }
+    }
+}
index 2d468f7164a0b7c7316c09403bacba418252f94c..34727ca43a0b636ea1aec830c2a24d10a8a06d6d 100644 (file)
@@ -29,6 +29,7 @@ use yii_app\helpers\DataHelper;
  * @property int|null $updated_at
  * @property string|null $deleted_at
  * @property int|null $deleted_by
+ * @property int|null $is_feed_active
  */
 class MatrixErp extends \yii\db\ActiveRecord
 {
@@ -62,7 +63,7 @@ class MatrixErp extends \yii\db\ActiveRecord
         return [
             [['guid', 'date_from'], 'required'],
             [['updated_at', 'created_at'], 'safe'],
-            [['category_id', 'active', 'created_admin_id', 'updated_admin_id'], 'integer'],
+            [['category_id', 'active', 'created_admin_id', 'updated_admin_id', 'is_feed_active'], 'integer'],
             [['components', 'deleted_at'], 'string'],
             [['id', 'deleted_by'], 'integer'],
             [['guid', 'parent_id', 'group_name', 'code', 'articule', 'date_from', 'date_to'], 'string', 'max' => 100],
@@ -92,6 +93,7 @@ class MatrixErp extends \yii\db\ActiveRecord
             'created_at' => 'Created At',
             'updated_admin_id' => 'Updated Admin ID',
             'updated_at' => 'Updated At',
+            'is_feed_active' => 'Фид товаров',
         ];
     }