From: fomichev Date: Thu, 16 Jan 2025 11:58:10 +0000 (+0300) Subject: Создание миграций справочников X-Git-Tag: 1.7~68^2~2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=9379c447288bf0906de7b878185155da6f92ad26;p=erp24_rep%2Fyii-erp24%2F.git Создание миграций справочников --- 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); + } + } +}