From: fomichev Date: Tue, 21 Apr 2026 12:58:08 +0000 (+0300) Subject: migration X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=f23b9b18968b3408c1c4a2fdc87dc2a7de9fadaa;p=erp24_rep%2Fyii-erp24%2F.git migration --- 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 index 00000000..ca6276b8 --- /dev/null +++ b/erp24/migrations/m260420_145000_add_deleted_at_to_product_mappings.php @@ -0,0 +1,37 @@ +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'); + } +}