From: Vladimir Fomichev Date: Fri, 3 Oct 2025 14:22:01 +0000 (+0300) Subject: миграция X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=c385a8e74aa144e81b395ea5d6ab02b018c7f045;p=erp24_rep%2Fyii-erp24%2F.git миграция --- 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); + } } }