]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Миграция
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 14 Feb 2025 10:48:44 +0000 (13:48 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 14 Feb 2025 10:48:44 +0000 (13:48 +0300)
erp24/migrations/m250214_090458_add_column_resource_link_to_wiki_article_table.php [new file with mode: 0644]

diff --git a/erp24/migrations/m250214_090458_add_column_resource_link_to_wiki_article_table.php b/erp24/migrations/m250214_090458_add_column_resource_link_to_wiki_article_table.php
new file mode 100644 (file)
index 0000000..c58dca3
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m250214_090458_add_column_resource_link_to_wiki_article_table
+ */
+class m250214_090458_add_column_resource_link_to_wiki_article_table extends Migration
+{
+    const TABLE_NAME  = 'erp24.wiki_article';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME) === null) {
+            return;
+        }
+
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME)->getColumn('resource_link') === null) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'resource_link',
+                $this->string()->null()->comment('Ссылка на ресурс для документации'),
+            );
+        }
+
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME) === null) {
+            return;
+        }
+
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME)->getColumn('resource_link') !== null) {
+            $this->dropColumn(self::TABLE_NAME, 'resource_link');
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m250214_090458_add_column_resource_link_to_wiki_article_table cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}