diff --git a/changes/236.canada.bugfix b/changes/236.canada.bugfix new file mode 100644 index 00000000000..24975df8312 --- /dev/null +++ b/changes/236.canada.bugfix @@ -0,0 +1 @@ +Fixed an issue with the `datastore purge` command deleting custom Reference Tables. diff --git a/ckanext/datastore/cli.py b/ckanext/datastore/cli.py index 61fc1739fe9..7185a158302 100644 --- a/ckanext/datastore/cli.py +++ b/ckanext/datastore/cli.py @@ -144,6 +144,11 @@ def purge(list: bool = False, yes: bool = False): site_user = logic.get_action('get_site_user')({'ignore_auth': True}, {}) + # (canada fork only): skip underscored tables, + # skip public_table_search tables + # TODO: upstream contrib!! + public_search_tables = config.get('ckan.datastore.public_table_search', []) + resource_id_list = [] # (canada fork only): more options and state=deleted handling # TODO: upstream contrib!! @@ -166,6 +171,14 @@ def purge(list: bool = False, yes: bool = False): if record['alias_of']: continue + # (canada fork only): skip underscored tables, + # skip public_table_search tables + # TODO: upstream contrib!! + if record['name'] in public_search_tables: + continue + if record['name'].startswith('_'): + continue + # (canada fork only): more options and state=deleted handling # TODO: upstream contrib!! res = logic.get_action('resource_show')(