]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
migration
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 21 Apr 2026 12:58:08 +0000 (15:58 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 21 Apr 2026 12:58:08 +0000 (15:58 +0300)
erp24/migrations/m260420_145000_add_deleted_at_to_product_mappings.php [new file with mode: 0644]

diff --git a/erp24/migrations/m260420_145000_add_deleted_at_to_product_mappings.php b/erp24/migrations/m260420_145000_add_deleted_at_to_product_mappings.php
new file mode 100644 (file)
index 0000000..ca6276b
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * ERP-300: Добавить is_active в product_mappings (soft-delete, как во всех остальных таблицах справочника).
+ */
+class m260420_145000_add_deleted_at_to_product_mappings extends Migration
+{
+    private const TABLE = 'erp24.product_mappings';
+
+    public function safeUp(): void
+    {
+        if (!$this->db->getTableSchema(self::TABLE)) {
+            echo "Таблица " . self::TABLE . " не найдена, пропускаем.\n";
+            return;
+        }
+
+        $schema = $this->db->getTableSchema(self::TABLE);
+        if (isset($schema->columns['is_active'])) {
+            echo "Колонка is_active уже существует, пропускаем.\n";
+            return;
+        }
+
+        $this->addColumn(self::TABLE, 'is_active', $this->boolean()->notNull()->defaultValue(true)->comment('Активен (soft delete)'));
+        $this->createIndex('idx_pm_is_active', self::TABLE, 'is_active');
+    }
+
+    public function safeDown(): void
+    {
+        if (!$this->db->getTableSchema(self::TABLE)) {
+            return;
+        }
+        $this->dropIndex('idx_pm_is_active', self::TABLE);
+        $this->dropColumn(self::TABLE, 'is_active');
+    }
+}