Not the answer you need?
Register and ask your own question!

pt-archive fk constraints

smith18smith18 EntrantCurrent User Role Beginner
How does pt-archiver handle foreign keys?

Does it archive associated data? (seems not but the documentation is not very clear to me)

And if not, how could one perform an archive of a table with all its associated data from other tables also being archived?

The documentation for custom module/plugin says that we can achieve this

before_delete(row => @row) This method is called for each row just before it is deleted. This applies only to --source. This is a good place for you to handle dependencies, such as deleting things that are foreign-keyed to the row you are about to delete. You could also use this to recursively archive all dependent tables.

....

before_insert(row => @row) This method is called for each row just before it is inserted. This applies only to --dest. You could use this to insert the row into multiple tables, perhaps with an ON DUPLICATE KEY UPDATE clause to build summary tables in a data warehouse.

but not how one can achieve this

Any experiences with this tool for this kind of of usecase?
how does table handle fk constraints? any idea or thought would be appropriated

Comments

  • smith18smith18 Entrant Current User Role Beginner
    please help
  • carlos.salguerocarlos.salguero Percona Toolkit Developer Percona Staff Role
    Hi,

    I would use a different method for the custom plugin (you need to write your own plugin): is_archivable
    You can write a custom is_archivable method that checks if that value is still being used from a different table but, I think the correct way to handle this is not by using a custom plugin.
    Instead of using a custom plugin I would first check the ON DELETE part of your FK definition.

    Regards
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.