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

Add missing index renaming when completing a migration #577

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Jan 8, 2025

During testing the faithful duplication of indexed columns I discovered that
if a column is included in multiple indices the only one of the indices are renamed. It happened because the index was deleted from the bookkeeper in the table even if the index was not renamed.

postgres=# \d items
                                          Table "public.items"
 Column |          Type          | Collation | Nullable |                    Default
--------+------------------------+-----------+----------+-----------------------------------------------
 id     | integer                |           | not null | nextval('_pgroll_new_items_id_seq'::regclass)
 city   | character varying(255) |           |          |
 name   | character varying(255) |           |          |
Indexes:
    "_pgroll_new_items_pkey" PRIMARY KEY, btree (id)
    "_pgroll_dup_idx_items_unique_name" UNIQUE, btree (name)
    "items_unique_name_id" UNIQUE CONSTRAINT, btree (city, name)

Correct output after my fix:

postgres=# \d items
                                          Table "public.items"
 Column |          Type          | Collation | Nullable |                    Default
--------+------------------------+-----------+----------+-----------------------------------------------
 id     | integer                |           | not null | nextval('_pgroll_new_items_id_seq'::regclass)
 city   | character varying(255) |           |          |
 name   | character varying(255) |           |          |
Indexes:
    "_pgroll_new_items_pkey" PRIMARY KEY, btree (id)
    "idx_items_unique_name" UNIQUE, btree (name)
    "items_unique_name_id" UNIQUE CONSTRAINT, btree (city, name)

@kvch kvch requested a review from andrew-farries January 8, 2025 14:38
@kvch kvch enabled auto-merge (squash) January 8, 2025 14:39
@kvch kvch merged commit baa4513 into xataio:main Jan 8, 2025
28 checks passed
@ryanslade
Copy link
Collaborator

Might be worth adding a test for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants