From f23b9b18968b3408c1c4a2fdc87dc2a7de9fadaa Mon Sep 17 00:00:00 2001 From: fomichev Date: Tue, 21 Apr 2026 15:58:08 +0300 Subject: [PATCH] migration --- ...000_add_deleted_at_to_product_mappings.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 erp24/migrations/m260420_145000_add_deleted_at_to_product_mappings.php 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'); + } +} -- 2.39.5