From 0b5fd48ac7b64d36af79fa9079786e1fc2d6bddd Mon Sep 17 00:00:00 2001 From: fomichev Date: Thu, 16 Jan 2025 17:11:32 +0300 Subject: [PATCH] =?utf8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?utf8?q?=20=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81?= =?utf8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BD=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ..._112712_create_store_region_list_table.php | 43 ---------------- ...16_112743_create_store_city_list_table.php | 14 +++++- ...12755_create_store_district_list_table.php | 49 ------------------- 3 files changed, 13 insertions(+), 93 deletions(-) delete mode 100644 erp24/migrations/m250116_112712_create_store_region_list_table.php delete mode 100644 erp24/migrations/m250116_112755_create_store_district_list_table.php diff --git a/erp24/migrations/m250116_112712_create_store_region_list_table.php b/erp24/migrations/m250116_112712_create_store_region_list_table.php deleted file mode 100644 index 810f7ef8..00000000 --- a/erp24/migrations/m250116_112712_create_store_region_list_table.php +++ /dev/null @@ -1,43 +0,0 @@ -db->getTableSchema(self::TABLE_NAME); - - if (!isset($tableSchema)) { - $this->createTable(self::TABLE_NAME, [ - 'id' => $this->primaryKey()->comment('Первичный ключ'), - 'name' => $this->string()->notNull()->comment('Регион'), - 'code' => $this->integer()->notNull()->comment('Код региона'), - 'okrug' => $this->string()->notNull()->comment('Округ'), - 'created_at' => $this->dateTime() - ->notNull() - ->defaultExpression('CURRENT_TIMESTAMP') - ->comment('Дата создания записи'), - ]); - - } - } - - /** - * {@inheritdoc} - */ - public function safeDown() - { - $tableSchema = $this->db->getTableSchema(self::TABLE_NAME); - if (isset($tableSchema)) { - $this->dropTable(self::TABLE_NAME); - } - } -} diff --git a/erp24/migrations/m250116_112743_create_store_city_list_table.php b/erp24/migrations/m250116_112743_create_store_city_list_table.php index ad7231d1..bb29d302 100644 --- a/erp24/migrations/m250116_112743_create_store_city_list_table.php +++ b/erp24/migrations/m250116_112743_create_store_city_list_table.php @@ -18,13 +18,24 @@ class m250116_112743_create_store_city_list_table extends Migration if (!isset($tableSchema)) { $this->createTable(self::TABLE_NAME, [ 'id' => $this->primaryKey()->comment('Первичный ключ'), - 'name' => $this->string()->notNull()->comment('Город'), + 'parent_id' => $this->integer()->null()->comment('Идентификатор родителя'), + 'name' => $this->string()->notNull()->comment('Название (регион, город, район)'), + 'type' => $this->string()->notNull()->comment('Тип (region, city, district)'), 'created_at' => $this->dateTime() ->notNull() ->defaultExpression('CURRENT_TIMESTAMP') ->comment('Дата создания записи'), ]); + $this->addForeignKey( + 'fk-store_city_list-parent_id', + self::TABLE_NAME, + 'parent_id', + self::TABLE_NAME, + 'id', + 'SET NULL', + 'SET NULL' + ); } } @@ -35,6 +46,7 @@ class m250116_112743_create_store_city_list_table extends Migration { $tableSchema = $this->db->getTableSchema(self::TABLE_NAME); if (isset($tableSchema)) { + $this->dropForeignKey('fk-store_city_list-parent_id', self::TABLE_NAME); $this->dropTable(self::TABLE_NAME); } } diff --git a/erp24/migrations/m250116_112755_create_store_district_list_table.php b/erp24/migrations/m250116_112755_create_store_district_list_table.php deleted file mode 100644 index 8dcdf3f0..00000000 --- a/erp24/migrations/m250116_112755_create_store_district_list_table.php +++ /dev/null @@ -1,49 +0,0 @@ -db->getTableSchema(self::TABLE_NAME); - - if (!isset($tableSchema)) { - $this->createTable(self::TABLE_NAME, [ - 'id' => $this->primaryKey()->comment('Первичный ключ'), - 'name' => $this->string()->notNull()->comment('Район'), - 'city_id' => $this->integer()->notNull()->comment('ID города'), - 'created_at' => $this->dateTime() - ->notNull() - ->defaultExpression('CURRENT_TIMESTAMP') - ->comment('Дата создания записи'), - ]); - $this->addForeignKey( - 'fk-city_id', - self::TABLE_NAME, - 'city_id', - 'erp24.store_city_list', - 'id', - ); - - } - } - - /** - * {@inheritdoc} - */ - public function safeDown() - { - $tableSchema = $this->db->getTableSchema(self::TABLE_NAME); - if (isset($tableSchema)) { - $this->dropTable(self::TABLE_NAME); - } - } -} -- 2.39.5