From c14ff3b5380c357cb622f5d36d52bae615ee1a94 Mon Sep 17 00:00:00 2001 From: fomichev Date: Sat, 2 Nov 2024 16:52:54 +0300 Subject: [PATCH] =?utf8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB=20=D1=82?= =?utf8?q?=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ...4933_create_product_1c_prop_type_table.php | 33 +++++++++++++ ...956_create_product_1c_prop_value_table.php | 47 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 erp24/migrations/m241102_124933_create_product_1c_prop_type_table.php create mode 100644 erp24/migrations/m241102_124956_create_product_1c_prop_value_table.php diff --git a/erp24/migrations/m241102_124933_create_product_1c_prop_type_table.php b/erp24/migrations/m241102_124933_create_product_1c_prop_type_table.php new file mode 100644 index 00000000..97cce874 --- /dev/null +++ b/erp24/migrations/m241102_124933_create_product_1c_prop_type_table.php @@ -0,0 +1,33 @@ +createTable(self::TABLE_NAME, [ + 'id' => $this->string()->notNull()->unique()->comment('Идентификатор из 1С'), + 'alias' => $this->string()->notNull()->comment('Алиас свойства'), + 'value' => $this->string()->notNull()->comment('Значение - например, "Срезка"'), + ]); + + $this->addPrimaryKey('pk_product_1c_prop_type', self::TABLE_NAME, 'id'); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropTable(self::TABLE_NAME); + } +} diff --git a/erp24/migrations/m241102_124956_create_product_1c_prop_value_table.php b/erp24/migrations/m241102_124956_create_product_1c_prop_value_table.php new file mode 100644 index 00000000..ca1ab185 --- /dev/null +++ b/erp24/migrations/m241102_124956_create_product_1c_prop_value_table.php @@ -0,0 +1,47 @@ +createTable(self::TABLE_NAME, [ + 'id' => $this->string()->notNull()->unique()->comment('Идентификатор значения в системе 1С'), + 'prop_id' => $this->string()->notNull()->comment('Идентификатор свойства для которого присваивается значение'), + 'value_type' => $this->string()->notNull()->comment('Тип данных значения'), + 'value_string' => $this->string()->null()->comment('String '), + 'value_int' => $this->integer()->null()->comment('Integer'), + 'value_float' => $this->float()->null()->comment('Float'), + ]); + + $this->addPrimaryKey('pk_product_1c_prop_value', self::TABLE_NAME, 'id'); + $this->addForeignKey( + 'fk_product_1c_prop_value_prop_id', + self::TABLE_NAME, + 'prop_id', + '{{%erp24.product_1c_prop_type}}', + 'id', + 'CASCADE', + 'CASCADE' + ); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropForeignKey('fk_product_1c_prop_value_prop_id', self::TABLE_NAME); + $this->dropTable(self::TABLE_NAME); + + } +} -- 2.39.5