Skip to content

Commit

Permalink
[CELEBORN-1297][FOLLOWUP] Fix DB config service SQL file
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

Fix the unique key to reflect correct columns names.

### Why are the changes needed?

Running current DB scripts give below error because `user` column was renamed to `name` (#2340) but the unique key was not updated correctly.

```
mysql> CREATE TABLE IF NOT EXISTS celeborn_cluster_tenant_config
    -> (
    ->     id           int          NOT NULL AUTO_INCREMENT,
    ->     cluster_id   int          NOT NULL,
    ->     tenant_id    varchar(255) NOT NULL,
    ->     level        varchar(255) NOT NULL COMMENT 'config level, valid level is TENANT,USER',
    ->     name         varchar(255) DEFAULT NULL COMMENT 'tenant sub user',
    ->     config_key   varchar(255) NOT NULL,
    ->     config_value varchar(255) NOT NULL,
    ->     type         varchar(255) DEFAULT NULL COMMENT 'conf categories, such as quota',
    ->     gmt_create   timestamp NOT NULL,
    ->     gmt_modify   timestamp NOT NULL,
    ->     PRIMARY KEY (id),
    ->     UNIQUE KEY `index_unique_tenant_config_key` (`cluster_id`, `tenant_id`, `user`, `config_key`)
    -> );
ERROR 1072 (42000): Key column 'user' doesn't exist in table
```

### Does this PR introduce _any_ user-facing change?

NA

### How was this patch tested?

Tested in local DB
```
mysql> CREATE TABLE IF NOT EXISTS celeborn_cluster_tenant_config
    -> (
    ->     id           int          NOT NULL AUTO_INCREMENT,
    ->     cluster_id   int          NOT NULL,
    ->     tenant_id    varchar(255) NOT NULL,
    ->     level        varchar(255) NOT NULL COMMENT 'config level, valid level is TENANT,USER',
    ->     name         varchar(255) DEFAULT NULL COMMENT 'tenant sub user',
    ->     config_key   varchar(255) NOT NULL,
    ->     config_value varchar(255) NOT NULL,
    ->     type         varchar(255) DEFAULT NULL COMMENT 'conf categories, such as quota',
    ->     gmt_create   timestamp NOT NULL,
    ->     gmt_modify   timestamp NOT NULL,
    ->     PRIMARY KEY (id),
    ->     UNIQUE KEY `index_unique_tenant_config_key` (`cluster_id`, `tenant_id`, `name`, `config_key`)
    -> );
Query OK, 0 rows affected (0.01 sec)
```

Closes #2740 from s0nskar/fix-db-script.

Authored-by: Sanskar Modi <[email protected]>
Signed-off-by: Shuang <[email protected]>
(cherry picked from commit b3f86f9)
Signed-off-by: Shuang <[email protected]>
  • Loading branch information
s0nskar authored and RexXiong committed Sep 17, 2024
1 parent d494049 commit ee37b6d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/developers/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ CREATE TABLE IF NOT EXISTS celeborn_cluster_tenant_config (
gmt_create timestamp NOT NULL,
gmt_modify timestamp NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY `index_unique_tenant_config_key` (`cluster_id`, `tenant_id`, `user`, `config_key`)
UNIQUE KEY `index_unique_tenant_config_key` (`cluster_id`, `tenant_id`, `name`, `config_key`)
);

INSERT INTO celeborn_cluster_info ( `id`, `name`, `namespace`, `endpoint`, `gmt_create`, `gmt_modify` )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ CREATE TABLE IF NOT EXISTS celeborn_cluster_tenant_config
gmt_create timestamp NOT NULL,
gmt_modify timestamp NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY `index_unique_tenant_config_key` (`cluster_id`, `tenant_id`, `user`, `config_key`)
UNIQUE KEY `index_unique_tenant_config_key` (`cluster_id`, `tenant_id`, `name`, `config_key`)
);

0 comments on commit ee37b6d

Please sign in to comment.