danhuawang opened a new issue, #12516:
URL: https://github.com/apache/gravitino/issues/12516
## What would you like to be improved?
Several upgrade SQL scripts contain `CREATE INDEX` statements without `IF
NOT EXISTS`, which causes errors when the migration is re-run (e.g., during
retry scenarios or when running upgrade scripts in sequence from an arbitrary
starting version).
Affected files:
- `scripts/postgresql/upgrade-1.1.0-to-1.2.0-postgresql.sql` (5 occurrences):
- `CREATE INDEX idx_function_meta_metalake_id`
- `CREATE INDEX idx_function_meta_catalog_id`
- `CREATE INDEX idx_function_version_metalake_id`
- `CREATE INDEX idx_function_version_catalog_id`
- `CREATE INDEX idx_function_version_schema_id`
- `scripts/mysql/upgrade-1.2.0-to-1.3.0-mysql.sql` (3 occurrences):
- `CREATE INDEX idx_user_meta_name_del_upd`
- `CREATE INDEX idx_owner_meta_del_upd_obj`
- `CREATE INDEX idx_group_meta_name_del_upd`
- `scripts/mysql/upgrade-1.3.0-to-2.0.0-mysql.sql` (1 occurrence):
- `CREATE INDEX idx_tid_value`
When these scripts are executed more than once, PostgreSQL raises `ERROR:
relation "..." already exists` and MySQL raises `Duplicate key name`. This
blocks automated upgrade tooling that applies all scripts sequentially for
safety.
## How should we improve?
For PostgreSQL: add `IF NOT EXISTS` to all affected `CREATE INDEX`
statements.
For MySQL: MySQL 8.0.x does not support `CREATE INDEX IF NOT EXISTS`. The
recommended approach is to use `DROP INDEX IF EXISTS ... ON <table>` before the
`CREATE INDEX`, or conditionally skip via a stored procedure.
--
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]