From c385a8e74aa144e81b395ea5d6ab02b018c7f045 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Fri, 3 Oct 2025 17:22:01 +0300 Subject: [PATCH] =?utf8?q?=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ...craete_table_self_cost_product_dynamic.php | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/erp24/migrations/m250925_231312_craete_table_self_cost_product_dynamic.php b/erp24/migrations/m250925_231312_craete_table_self_cost_product_dynamic.php index 8d4df58b..00060a67 100644 --- a/erp24/migrations/m250925_231312_craete_table_self_cost_product_dynamic.php +++ b/erp24/migrations/m250925_231312_craete_table_self_cost_product_dynamic.php @@ -14,16 +14,20 @@ class m250925_231312_craete_table_self_cost_product_dynamic extends Migration */ public function safeUp() { - $this->createTable(self::TABLE_NAME, [ - 'id' => $this->bigPrimaryKey(), - 'store_id' => $this->integer()->notNull(), - 'product_guid' => $this->string()->notNull()->comment('product guid'), - 'price' => $this->float()->notNull()->comment('price'), - 'date_from' => $this->date()->notNull()->comment('Дата начала'), - 'date_to' => $this->date()->defaultValue('2100-01-01')->notNull()->comment('Дата окончания'), - 'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()')->comment('Дата создания записи'), - 'updated_at' => $this->datetime()->null()->comment('Дата внесения записи'), - ]); + $tableSchema = $this->db->getTableSchema(self::TABLE_NAME); + + if (!isset($tableSchema)) { + $this->createTable(self::TABLE_NAME, [ + 'id' => $this->bigPrimaryKey(), + 'store_id' => $this->integer()->notNull(), + 'product_guid' => $this->string()->notNull()->comment('product guid'), + 'price' => $this->float()->notNull()->comment('price'), + 'date_from' => $this->date()->notNull()->comment('Дата начала'), + 'date_to' => $this->date()->defaultValue('2100-01-01')->notNull()->comment('Дата окончания'), + 'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()')->comment('Дата создания записи'), + 'updated_at' => $this->datetime()->null()->comment('Дата внесения записи'), + ]); + } } /** @@ -31,6 +35,9 @@ class m250925_231312_craete_table_self_cost_product_dynamic extends Migration */ public function safeDown() { - $this->dropTable(self::TABLE_NAME); + $tableSchema = $this->db->getTableSchema(self::TABLE_NAME); + if (isset($tableSchema)) { + $this->dropTable(self::TABLE_NAME); + } } } -- 2.39.5