From 9379c447288bf0906de7b878185155da6f92ad26 Mon Sep 17 00:00:00 2001 From: fomichev Date: Thu, 16 Jan 2025 14:58:10 +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=B9=20=D1=81?= =?utf8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BD=D0=B8=D0=BA=D0=BE?= =?utf8?q?=D0=B2?= 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 | 41 ++++++++++++++++ ...12755_create_store_district_list_table.php | 49 +++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 erp24/migrations/m250116_112712_create_store_region_list_table.php create mode 100644 erp24/migrations/m250116_112743_create_store_city_list_table.php create 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 new file mode 100644 index 00000000..810f7ef8 --- /dev/null +++ b/erp24/migrations/m250116_112712_create_store_region_list_table.php @@ -0,0 +1,43 @@ +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 new file mode 100644 index 00000000..ad7231d1 --- /dev/null +++ b/erp24/migrations/m250116_112743_create_store_city_list_table.php @@ -0,0 +1,41 @@ +db->getTableSchema(self::TABLE_NAME); + + if (!isset($tableSchema)) { + $this->createTable(self::TABLE_NAME, [ + 'id' => $this->primaryKey()->comment('Первичный ключ'), + 'name' => $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_112755_create_store_district_list_table.php b/erp24/migrations/m250116_112755_create_store_district_list_table.php new file mode 100644 index 00000000..8dcdf3f0 --- /dev/null +++ b/erp24/migrations/m250116_112755_create_store_district_list_table.php @@ -0,0 +1,49 @@ +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