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 »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • easy way to delete members using database tables?
Pages: [1]

Author Topic: easy way to delete members using database tables?  (Read 993 times)

webguy2

  • Guest
easy way to delete members using database tables?
September 11, 2009, 04:30:01 pm
the system is slow removing memberships even my local server.  is there a way to us database commands or the database tables to delete members?  If so, which tables are involved to completely remove a member relationship to a contact?  I want to keep the contact data.

Thanks.

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: easy way to delete members using database tables?
September 14, 2009, 02:57:42 am
I think we should use civicrm delete functionality to delete membership records, please don't use direct sql query.
There are few directly / indirectly related objects to that of membership object and when we delete membership object we has to have cleanup all these related objects.

but still if you want sql query to cleanup membership records, this query might going to serve needful -
Quote
   DELETE  memberActivity.*, contributionActivity.*, contribution.*, payment.* , member.*
      FROM  civicrm_membership member
LEFT JOIN  civicrm_membership_payment payment ON ( payment.membership_id = member.id )
LEFT JOIN  civicrm_contribution contribution ON ( contribution.id = payment.contribution_id )
LEFT JOIN  civicrm_activity memberActivity ON ( memberActivity.source_record_id = member.id AND memberActivity.activity_type_id = 7 )
LEFT JOIN  civicrm_activity contributionActivity ON ( contributionActivity.source_record_id = contribution.id AND contributionActivity.activity_type_id = 6 )
you can restrict delete member operation by inserting needful where conditions.
( eg WHERE member.contact_id = 102 ) delete all membership records related to 102 contact id.

hope this help

kiran
You Are Designed To Choose... Defined By Choice.

webguy2

  • Guest
Re: easy way to delete members using database tables?
September 14, 2009, 06:20:25 am
thanks.  to clarify, your sql code deletes all remnants of the membership relationship but NOT the contact, right?

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: easy way to delete members using database tables?
September 14, 2009, 07:45:12 am
yes,  given sql query is not going to delete record from civicrm_contact table.

kiran
You Are Designed To Choose... Defined By Choice.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • easy way to delete members using database tables?

This forum was archived on 2017-11-26.