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

Ensure table names are unique and preset #37

Merged
merged 1 commit into from
Feb 15, 2022
Merged

Ensure table names are unique and preset #37

merged 1 commit into from
Feb 15, 2022

Conversation

shayonj
Copy link
Owner

@shayonj shayonj commented Feb 15, 2022

Since we are not restoring index/sequence name for now,
ensuring the table names are unique so that if we run the same
operation on the same table, there is no sequence conflict. The sequence
will get overriden on the table anyways, but won't fail and complain
when trying to create a shadow before the swap. This is temporary until
we support restoring original index and sequence names(#20). Can be a pro feature too

# Set this early on to ensure their creation and cleanup (unexpected)
# happens at all times. IOW, the calls from Store.get always return
# the same value.
Store.set(:old_primary_table, "pgosc_op_table_#{client.table}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make sure to set the maximum length of these table names to 63. In fact, all identifiers in postgresql are limited to NAMEDATALEN - 1 or 63.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep def! Since we change the sequence name too (so its unique between primary and shadow table), keeping it short is nice.

Just to future proof, i added a spec. They are between 20/21 char len.

Since we are not restoring index/sequence name for now,
ensuring the table names are unique so that if we run the same
operation on the same table, there is no sequence conflict. The sequence
will get overriden on the table anyways, but won't fail and complain
when trying to create a shadow before the swap. This is temporary until
we support restoring original index and sequence names. Can be a pro feature too
@shayonj shayonj merged commit 6d6b9cf into main Feb 15, 2022
@shayonj shayonj deleted the s/shadow-table branch February 15, 2022 23:42
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.

2 participants