-
Notifications
You must be signed in to change notification settings - Fork 19
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
Restore index, foreign key and sequence constraint names #20
Comments
I would like to express my heartfelt gratitude to you for your unwavering commitment to maintaining this invaluable utility. Your dedication to ensuring its continued functionality has not gone unnoticed, and I am truly appreciative of the effort you invest in this endeavor. With the utmost respect and appreciation, I kindly inquire if there have been any recent developments or updates with regard to the previously closed pull request (PR). Your guidance and insights on this matter would be greatly valued, as your expertise plays a pivotal role in shaping the utility's performance and efficiency. Once again, thank you ever so much for your tireless work in maintaining this utility, and I eagerly await any information you can share regarding the aforementioned PR. Your contributions are instrumental in enhancing our workflow, and your commitment to excellence is truly commendable. |
hey hey! Thanks for the message. I haven't thought about this much lately. Let me thinking about this weekend and get back. I agree, it'd be really nice to support this functionality. |
So, given that we use I think restoring to the original index name is going to be hard because the low level id (OID) of the table changes too (since we fork a new table and default to the new table as the primary table at the end of the However, we could at least remove As noted above, we will lose the original naming, but at least the name isn't littered with the shadow table naming convention. We can do the same for sequences too. Curious if folks have thoughts here (cc @jfrost). Tagging explicitly based on the emoji reaction |
We could hang onto the index names from the original table and then rename the new indexes after table drop if |
I'd vote for renaming the original table's indexes after swap, then rename the new table's indexes to match the original names, as @jfrost mentioned. This would work even if the user does pass the |
|
I think the tricky bit is creating a map of old index names and the new index names. Since a column can have multiple indexes, and a user could've use custom naming for index, I wonder if there is a reliable way of mapping a column (or a composite/set of columns) against an index name. And accordingly derive indexes based on column names, so we can accordingly rename post swap. Let me know in case it doesn't make sense. I will give it a bit more thought later and get back. |
@shayonj I'm not sure what you're asking exactly. We have all the index names and index definitions for each table available in We're already grabbing that info here: pg-osc/lib/pg_online_schema_change/query.rb Lines 124 to 135 in aa29495
Are you thinking that we need to know the column names in the index in order to rename them? We don't, we can just cache the index names and then rename them all with something like:
That's obviously oversimplified, but it seems doable at first glance. |
Sorry for the late reply - Yeah i was talking about this line:
Basically, when we create the shadow table with But yes, I think what we can do is take control of the index building/adding process and that way we can build the in-memory map of the old index names and rename them again post cutover. Which should work like you mentioned. Its a bit of work, but I think def achievable for indexes. We will then have to do the same for sequences (right now we "fix" it here:
|
The naming can get weird or look weird when you pgosc has run multiple times on a table. It will always prefix the the prefix_key and additional run into name length limit issues.
This also applies to sequence names.
Can happen as part of cleanup.
The text was updated successfully, but these errors were encountered: