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

Safe to rename a partitioned table #747

Open
sposerina opened this issue Feb 6, 2025 · 5 comments
Open

Safe to rename a partitioned table #747

sposerina opened this issue Feb 6, 2025 · 5 comments
Assignees

Comments

@sposerina
Copy link

I'm attempting to migrate an existing table to a native partitioned table managed by partman. Once the copy of the data from the existing table is complete I want to rename the partitioned table to the existing table. Is there any problem with renaming all the partitions, renaming the template table, and upating the row in part_config for the partitioned table to reflect the exising name? Any other concerns modifying the partman config tables in this manner?

@keithf4
Copy link
Collaborator

keithf4 commented Feb 6, 2025

I think you've covered everything there. Also make sure to update the template table name in the part_config table as well.

This document was my attempt at a process to convert an existing partition set to partman so hopefully it helps

https://github.com/pgpartman/pg_partman/blob/development/doc/migrate_to_partman.md

@sposerina
Copy link
Author

Thanks for the confirmation. If I understand this correctly renaming contraints and partitions isn't necessary but is just good practice to keep everything clean. The only thing that needs to change is parent_name in the part_config, the name of the template table, and the column that references that table in part_config. If this data is wrong the partition manager will fail to create new partitions when maintenace is run.

@keithf4
Copy link
Collaborator

keithf4 commented Feb 10, 2025

I believe that's correct. Would still recommend testing first just to be sure.

@sposerina
Copy link
Author

I made the changes listed and tested by upating the premake parameter, running partition maintenance, and inserting a record into one of the newly created partitions. All appears well. Anything else to test? I'll close the issue if adequate.

@keithf4
Copy link
Collaborator

keithf4 commented Feb 24, 2025

Nothing else I can think of. If anything comes up, please feel free to make an issue and I can look into it.

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