[KYUUBI #6066] Fix PostgreSQL metastore migration script failure if indexes already exist

# 🔍 Description
## Issue References 🔗

This pull request is a small fix for #5674

## Describe Your Solution 🔧

PostgreSQL support as backend for metadata store was added in #6027. If we choose it and run schema init scripts several times, then the following errors will be logged: `Error executing sql: CREATE UNIQUE INDEX unique_identifier_index ON metadata(identifier), with params: . ERROR: relation "unique_identifier_index" already exists`. This PR adds lacking `IF NOT EXISTS` to db indexes creation ddls in the PostgreSQL metastore init script.

## Types of changes 🔖

- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests

---

# Checklist 📝

- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

Closes #6066 from tigrulya-exe/feature/5674-postgresql-metadata-backend.

Closes #6066

bb6487c16 [Tigran Manasyan] Fix PostgreSQL metastore migration script failure if indexes already exist

Authored-by: Tigran Manasyan <t.manasyan@arenadata.io>
Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
Tigran Manasyan 2024-02-20 23:05:30 +08:00 committed by Cheng Pan
parent f61338db49
commit 3a765079db
No known key found for this signature in database
GPG Key ID: 8001952629BCC75D

View File

@ -52,8 +52,8 @@ COMMENT ON COLUMN metadata.end_time IS 'the metadata end time';
COMMENT ON COLUMN metadata.priority IS 'the application priority, high value means high priority';
COMMENT ON COLUMN metadata.peer_instance_closed IS 'closed by peer kyuubi instance';
CREATE UNIQUE INDEX unique_identifier_index ON metadata(identifier);
CREATE INDEX user_name_index ON metadata(user_name);
CREATE INDEX engine_type_index ON metadata(engine_type);
CREATE INDEX create_time_index ON metadata(create_time);
CREATE INDEX priority_create_time_index ON metadata(priority DESC, create_time ASC);
CREATE UNIQUE INDEX IF NOT EXISTS unique_identifier_index ON metadata(identifier);
CREATE INDEX IF NOT EXISTS user_name_index ON metadata(user_name);
CREATE INDEX IF NOT EXISTS engine_type_index ON metadata(engine_type);
CREATE INDEX IF NOT EXISTS create_time_index ON metadata(create_time);
CREATE INDEX IF NOT EXISTS priority_create_time_index ON metadata(priority DESC, create_time ASC);