Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when dealing with ALTER TABLE ... ADD INDEX #85

Closed
hahnn opened this issue Nov 27, 2023 · 0 comments
Closed

Error when dealing with ALTER TABLE ... ADD INDEX #85

hahnn opened this issue Nov 27, 2023 · 0 comments

Comments

@hahnn
Copy link

hahnn commented Nov 27, 2023

There is an issue with the conversion of the kind of SQL code below:

[1701096116.0262] Error running :
ALTER TABLE wp_e_events
                ADD INDEX `created_at_index` (`created_at`)

---- converted to ----
ALTER TABLE wp_e_events
                ADD INDEX created_at_index (created_at)
----> ERREUR:  le type « created_at_index » n'existe pas
LINE 2:       ADD INDEX created_at_index (created_at)
                        ^
---------------------

So:

ALTER TABLE <table_name> ADD [UNIQUE] INDEX <index_name> (<column1_name>, <column2_name>, ...)

should be converted to:

CREATE [UNIQUE] INDEX IF NOT EXISTS <index_name> ON <table_name> (<column1_name>, <column2_name>, ...)

Then for this specific case, the result of the conversion should be something like:

CREATE INDEX IF NOT EXISTS wp_e_events_created_at_index ON wp_e_events (created_at)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants