Hello @amaheer1
We are working on the issue to remove all data when the plugin is uninstalled, this will be released in the upcoming v2.2, you can follow this issue to know the progress.
https://github.com/ampproject/amp-wp/issues/3210
You can use the WP CLI command or SQL Queries to delete AMP plugins data.
Disclaimer: Run the below commands and SQL query at your own risk.
Note: Run them first in dev/pre-production environment to reduce the risk of losing the data.
We will recommend deleting the data with WP CLI, Run the following CLI commands.
WP CLI
1. Remove AMP settings data:
wp option delete amp-options
2. Remove all amp_validated_url posts:
wp post delete $(wp post list --post_type='amp_validated_url' --format=ids)
3. Remove all amp_validation_error terms:
wp term list amp_validation_error --field=term_id | xargs wp term delete amp_validation_error
SQL Queries
If you can access your site database using Cpanel or PHPmyadmin tool, you can delete AMP data using the following SQL queries
Execute them in the sequence they are provided ( check your table prefix and use that instead of wp_)
1. Remove AMP settings data:
DELETE FROM wp_options WHERE option_name LIKE 'amp-options'
2. Remove post meta ( if we use WP CLI it will be remove associated post meta )
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.post_type='amp_validated_url'
3. Remove all amp_validated_url posts
DELETE FROM wp_posts WHERE post_type = 'amp_validated_url'
4. Remove term meta
DELETE FROM wp_termmeta WHERE term_id IN ( SELECT term_id FROM wp_term_taxonomy WHERE taxonomy = 'amp_validation_error' )
5. Remove term relations
DELETE FROM wp_term_relationships WHERE term_taxonomy_id IN ( SELECT term_taxonomy_id FROM wp_term_taxonomy WHERE taxonomy = 'amp_validation_error' )
6. Remove terms
DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy = 'amp_validation_error' )
7. Remove taxonomies
DELETE FROM wp_term_taxonomy WHERE taxonomy = 'amp_validation_error'
Hope this helps!