CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Deleting a domain in 2.0.2
Pages: [1]

Author Topic: Deleting a domain in 2.0.2  (Read 1225 times)

myles

  • I post frequently
  • ***
  • Posts: 263
  • Karma: 11
Deleting a domain in 2.0.2
September 21, 2008, 06:19:16 am
The following script has worked for me - adapted from a post on the documentation site.

I strongly suggest that you check through on a test site before using it - See this as a starting point only!!!


-- /************* The following script deletes entries in a CiviCRM database in correct order for domain */
-- /************* Set the variable @deletion_domain_id to the number of the domain you wish to delete */

SELECT @deletion_domain_id := 3;

DELETE FROM `civicrm_contribution` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_uf_group` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_contribution_page` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_group` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_uf_match` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_custom_group` WHERE domain_id=@deletion_domain_id;

-- I have commented out deletions that attempted to delete tables that were not present

--DELETE FROM `civicrm_activity_type` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_membership_status` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_membership_type` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_task` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_project` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_product` WHERE domain_id=@deletion_domain_id;
--DELETE FROM `civicrm_accept_credit_card` WHERE domain_id=@deletion_domain_id;
--DELETE FROM `civicrm_payment_instrument` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_financial_trxn` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_contribution_type` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_mailing` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_mailing_component` WHERE domain_id=@deletion_domain_id;
-- This next one was an additional table with fk constraints
DELETE civicrm_mapping_field FROM
   civicrm_relationship_type
   Inner Join civicrm_mapping_field ON civicrm_relationship_type.id = civicrm_mapping_field.relationship_type_id
   WHERE civicrm_relationship_type.domain_id=1;DELETE FROM `civicrm_relationship_type` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_contact` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_option_group` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_dupe_match` WHERE domain_id=@deletion_domain_id;
--DELETE FROM `civicrm_validation` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_tag` WHERE domain_id=@deletion_domain_id;
--DELETE FROM `civicrm_mobile_provider` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_mapping` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_location_type` WHERE domain_id=@deletion_domain_id;
--DELETE FROM `civicrm_individual_suffix` WHERE domain_id=@deletion_domain_id;
--DELETE FROM `civicrm_individual_prefix` WHERE domain_id=@deletion_domain_id;
--DELETE FROM `civicrm_im_provider` WHERE domain_id=@deletion_domain_id;
--DELETE FROM `civicrm_gender` WHERE domain_id=@deletion_domain_id;
--DELETE FROM `civicrm_acl_group` WHERE domain_id=@deletion_domain_id;
-- new queries to delete tables that constrain other deletions
DELETE `civicrm_dedupe_rule`
   FROM
   `civicrm_dedupe_rule_group`
   Inner Join `civicrm_dedupe_rule` ON civicrm_dedupe_rule_group.id = civicrm_dedupe_rule.dedupe_rule_group_id
   WHERE civicrm_dedupe_rule_group.domain_id=@deletion_domain_id;
DELETE FROM `civicrm_dedupe_rule_group` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_payment_processor_type` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_preferences` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_preferences_date` WHERE domain_id=@deletion_domain_id;
DELETE FROM `civicrm_domain` WHERE id=@deletion_domain_id;


MichaƂ Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Deleting a domain in 2.0.2
September 22, 2008, 03:20:39 am
Thanks for sharing!

m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Deleting a domain in 2.0.2

This forum was archived on 2017-11-26.