From: fomichev Date: Thu, 14 May 2026 10:51:17 +0000 (+0300) Subject: правки по миграциям X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=bb892098b3da588ff9577ad32643504f46ac0c3a;p=erp24_rep%2Fyii-erp24%2F.git правки по миграциям --- diff --git a/erp24/migrations/m260420_120000_create_audit_log_table.php b/erp24/migrations/m260420_120000_create_audit_log_table.php index 7beaf9be..f9014be3 100644 --- a/erp24/migrations/m260420_120000_create_audit_log_table.php +++ b/erp24/migrations/m260420_120000_create_audit_log_table.php @@ -12,7 +12,7 @@ use yii\db\Migration; */ class m260420_120000_create_audit_log_table extends Migration { - private const TABLE = 'audit_log'; + private const TABLE = 'erp24.audit_log'; public function safeUp(): void { @@ -22,7 +22,7 @@ class m260420_120000_create_audit_log_table extends Migration // Родительская таблица с партиционированием по дате $this->db->createCommand(<<db->createCommand(<<execute(); $this->db->createCommand(<<execute(); $this->db->createCommand(<<execute(); $this->db->createCommand(<<execute(); // Кварталы 2027 $this->db->createCommand(<<execute(); $this->db->createCommand(<<execute(); $this->db->createCommand(<<execute(); $this->db->createCommand(<<execute(); // Индексы на родительской таблице — автоматически наследуются партициями в PG 11+ $this->db->createCommand(<<execute(); $this->db->createCommand(<<execute(); $this->db->createCommand(<<execute(); } public function safeDown(): void { // Партиции удаляются каскадно вместе с родительской таблицей - $this->db->createCommand('DROP TABLE IF EXISTS audit_log CASCADE')->execute(); + $this->db->createCommand('DROP TABLE IF EXISTS erp24.audit_log CASCADE')->execute(); } } diff --git a/erp24/migrations/m260420_130000_create_assortment_tables.php b/erp24/migrations/m260420_130000_create_assortment_tables.php index 7307dc5b..3a781b9a 100644 --- a/erp24/migrations/m260420_130000_create_assortment_tables.php +++ b/erp24/migrations/m260420_130000_create_assortment_tables.php @@ -8,8 +8,8 @@ use yii\db\Migration; */ class m260420_130000_create_assortment_tables extends Migration { - private const LABELS_TABLE = 'assortment_labels'; - private const ASSORTMENT_TABLE = 'product_assortment'; + private const LABELS_TABLE = 'erp24.assortment_labels'; + private const ASSORTMENT_TABLE = 'erp24.product_assortment'; public function safeUp(): void { diff --git a/erp24/migrations/m260420_140000_create_product_scores_table.php b/erp24/migrations/m260420_140000_create_product_scores_table.php index 973656d4..88c37fc6 100644 --- a/erp24/migrations/m260420_140000_create_product_scores_table.php +++ b/erp24/migrations/m260420_140000_create_product_scores_table.php @@ -8,7 +8,7 @@ use yii\db\Migration; */ class m260420_140000_create_product_scores_table extends Migration { - private const TABLE = 'product_scores'; + private const TABLE = 'erp24.product_scores'; public function safeUp(): void { diff --git a/erp24/migrations/m260420_150000_create_store_product_ratings_table.php b/erp24/migrations/m260420_150000_create_store_product_ratings_table.php index 93a57e7d..2b3e6cac 100644 --- a/erp24/migrations/m260420_150000_create_store_product_ratings_table.php +++ b/erp24/migrations/m260420_150000_create_store_product_ratings_table.php @@ -8,7 +8,7 @@ use yii\db\Migration; */ class m260420_150000_create_store_product_ratings_table extends Migration { - private const TABLE = 'store_product_ratings'; + private const TABLE = 'erp24.store_product_ratings'; public function safeUp(): void { diff --git a/erp24/migrations/m260422_100000_add_classification_fields_to_nomenclature.php b/erp24/migrations/m260422_100000_add_classification_fields_to_nomenclature.php index a07587ed..1409b546 100644 --- a/erp24/migrations/m260422_100000_add_classification_fields_to_nomenclature.php +++ b/erp24/migrations/m260422_100000_add_classification_fields_to_nomenclature.php @@ -9,7 +9,7 @@ use yii\db\Migration; */ class m260422_100000_add_classification_fields_to_nomenclature extends Migration { - private const TABLE = 'products_1c_nomenclature'; + private const TABLE = 'erp24.products_1c_nomenclature'; private const INDEX = 'idx_nomenclature_classification_status'; public function safeUp(): void diff --git a/erp24/migrations/m260422_110000_add_catmanager_rbac.php b/erp24/migrations/m260422_110000_add_catmanager_rbac.php index cc52f8ff..57fe5f5f 100644 --- a/erp24/migrations/m260422_110000_add_catmanager_rbac.php +++ b/erp24/migrations/m260422_110000_add_catmanager_rbac.php @@ -38,12 +38,12 @@ class m260422_110000_add_catmanager_rbac extends Migration public function safeDown(): void { $toRemove = [self::PERM_VIEW, self::PERM_MANAGE]; - $rows = $this->db->createCommand('SELECT id, config FROM admin_group_rbac_config')->queryAll(); + $rows = $this->db->createCommand('SELECT id, config FROM erp24.admin_group_rbac_config')->queryAll(); foreach ($rows as $row) { $perms = array_filter(array_map('trim', explode(',', (string)$row['config']))); $cleaned = array_values(array_diff($perms, $toRemove)); - $this->update('admin_group_rbac_config', ['config' => implode(',', $cleaned)], ['id' => $row['id']]); + $this->update('erp24.admin_group_rbac_config', ['config' => implode(',', $cleaned)], ['id' => $row['id']]); } \Yii::$app->cache->set('dirtyAuthSettings', true); @@ -52,12 +52,12 @@ class m260422_110000_add_catmanager_rbac extends Migration private function upsertGroupPermissions(int $groupId, array $permissions): void { $existing = $this->db->createCommand( - 'SELECT config FROM admin_group_rbac_config WHERE admin_group_id = :gid', + 'SELECT config FROM erp24.admin_group_rbac_config WHERE admin_group_id = :gid', [':gid' => $groupId] )->queryScalar(); if ($existing === false) { - $this->insert('admin_group_rbac_config', [ + $this->insert('erp24.admin_group_rbac_config', [ 'admin_group_id' => $groupId, 'config' => implode(',', $permissions), ]); @@ -65,7 +65,7 @@ class m260422_110000_add_catmanager_rbac extends Migration $current = array_filter(array_map('trim', explode(',', (string)$existing))); $merged = array_values(array_unique(array_merge($current, $permissions))); $this->update( - 'admin_group_rbac_config', + 'erp24.admin_group_rbac_config', ['config' => implode(',', $merged)], ['admin_group_id' => $groupId] ); diff --git a/erp24/migrations/m260422_120000_create_product_concepts_table.php b/erp24/migrations/m260422_120000_create_product_concepts_table.php index 6ad898b7..097ba9bf 100644 --- a/erp24/migrations/m260422_120000_create_product_concepts_table.php +++ b/erp24/migrations/m260422_120000_create_product_concepts_table.php @@ -16,7 +16,7 @@ use yii\db\Migration; */ class m260422_120000_create_product_concepts_table extends Migration { - private const TABLE = 'product_concepts'; + private const TABLE = 'erp24.product_concepts'; public function safeUp(): void { diff --git a/erp24/migrations/m260506_120000_add_automark_rbac_permissions.php b/erp24/migrations/m260506_120000_add_automark_rbac_permissions.php index 48264147..94ca9392 100644 --- a/erp24/migrations/m260506_120000_add_automark_rbac_permissions.php +++ b/erp24/migrations/m260506_120000_add_automark_rbac_permissions.php @@ -28,7 +28,8 @@ class m260506_120000_add_automark_rbac_permissions extends Migration AdminGroup::GROUP_KIK_MANAGER, // 82 ]; - private const AUTOMARK_TABLE = 'erp24.products_1c_automark_predictions'; + private const RBAC_CONFIG_TABLE = 'erp24.admin_group_rbac_config'; + private const AUTOMARK_TABLE = 'erp24.products_1c_automark_predictions'; private const COMPOUND_INDEX = 'idx_automark_status_llm_verdict'; public function safeUp(): void @@ -64,7 +65,7 @@ class m260506_120000_add_automark_rbac_permissions extends Migration { foreach (self::TARGET_GROUP_IDS as $groupId) { $row = (new \yii\db\Query()) - ->from('admin_group_rbac_config') + ->from(self::RBAC_CONFIG_TABLE) ->where(['admin_group_id' => $groupId]) ->one(); @@ -76,13 +77,13 @@ class m260506_120000_add_automark_rbac_permissions extends Migration } $existing[] = self::PERMISSION; $this->update( - 'admin_group_rbac_config', + self::RBAC_CONFIG_TABLE, ['config' => implode(',', $existing)], ['admin_group_id' => $groupId] ); echo " Группа {$groupId}: добавлено разрешение " . self::PERMISSION . "\n"; } else { - $this->insert('admin_group_rbac_config', [ + $this->insert(self::RBAC_CONFIG_TABLE, [ 'admin_group_id' => $groupId, 'config' => self::PERMISSION, ]); @@ -95,7 +96,7 @@ class m260506_120000_add_automark_rbac_permissions extends Migration { foreach (self::TARGET_GROUP_IDS as $groupId) { $row = (new \yii\db\Query()) - ->from('admin_group_rbac_config') + ->from(self::RBAC_CONFIG_TABLE) ->where(['admin_group_id' => $groupId]) ->one(); @@ -109,10 +110,10 @@ class m260506_120000_add_automark_rbac_permissions extends Migration )); if ($filtered === []) { - $this->delete('admin_group_rbac_config', ['admin_group_id' => $groupId]); + $this->delete(self::RBAC_CONFIG_TABLE, ['admin_group_id' => $groupId]); } else { $this->update( - 'admin_group_rbac_config', + self::RBAC_CONFIG_TABLE, ['config' => implode(',', $filtered)], ['admin_group_id' => $groupId] );