bharos commented on code in PR #13957:
URL: https://github.com/apache/gravitino/pull/13957#discussion_r4474072204


##########
scripts/mysql/schema-2.0.0-mysql.sql:
##########
@@ -424,6 +424,18 @@ CREATE TABLE IF NOT EXISTS `policy_tag_relation_meta` (
     KEY `policy_tag_relation_meta_idx_tag_id` (`tag_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT 'policy 
tag relation';
 
+CREATE TABLE IF NOT EXISTS `policy_role_relation_meta` (
+    `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'auto increment 
id',
+    `policy_id` BIGINT(20) UNSIGNED NOT NULL COMMENT 'policy id',
+    `role_name` VARCHAR(128) NOT NULL COMMENT 'role name referenced by the 
policy content',
+    `current_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'policy role 
relation current version',
+    `last_version` INT UNSIGNED NOT NULL DEFAULT 1 COMMENT 'policy role 
relation last version',
+    `deleted_at` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'policy role 
relation deleted at',
+    PRIMARY KEY (`id`),
+    UNIQUE KEY `policy_role_relation_meta_uk_pid_rn_del` (`policy_id`, 
`role_name`, `deleted_at`),

Review Comment:
   The table uses the same column type and collation as role_meta, so it 
resolves names exactly as the role table does — one role on MySQL, two on 
PostgreSQL. 
   I’d like to keep that: decoupling it would make listByRoleName miss 
references the role table considers the same role, which is the query role 
deletion depends on. The real defect was the reporting you spotted — the 
collision surfaced as “policy already exists”. It now fails against the role 
that collided, and there’s a test that asks role_meta which answer to expect, 
so it’s meaningful on all three backends.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to