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 (Moderator: Dave Greenberg) »
  • Smart group DB error - corrupted - want to delete it safely
Pages: [1]

Author Topic: Smart group DB error - corrupted - want to delete it safely  (Read 1736 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Smart group DB error - corrupted - want to delete it safely
March 30, 2011, 05:34:27 am
Hi there,

I have a smart group criteria that has gone wrong
Quote
SELECT
   contact_a.id as id
FROM civicrm_contact contact_a
LEFT JOIN civicrm_activity_target ON civicrm_activity_target.target_contact_id = contact_a.id
LEFT JOIN civicrm_activity ON ( civicrm_activity.id = civicrm_activity_target.activity_id AND civicrm_activity.is_deleted = 0 AND civicrm_activity.is_current_revision = 1 )

WHERE
   (
      civicrm_activity.activity_type_id IN (24)
      AND contact_b.is_deleted = 0
      AND contact_b.sort_name LIKE '%%'
      AND civicrm_activity.status_id IN (2)
   ) AND ( 1 )
   AND contact_a.id NOT IN (
      SELECT contact_id
      FROM civicrm_group_contact
      WHERE civicrm_group_contact.status = 'Removed' AND civicrm_group_contact.group_id = 7
   )

UNION
 
SELECT
   contact_id as id
FROM civicrm_group_contact
WHERE
   civicrm_group_contact.status = 'Added'
   AND civicrm_group_contact.group_id = 7

In case it isn't obvious (!) the error is "Unknown column 'contact_b.is_deleted' in 'where clause'"

Not sure why this went wrong (maybe something to do with an upgrade) and am happy to not know why it went wrong unless someone wants to tell me.

My question is how can I safely delete this smart group (with id 7)?

delete from civicrm_group where id = 7;
delete from civicrm_group_contact where group_id = 7;

There's nothing about groups that gets logged, AKAIK.  Anywhere else I should be deleting / things I should be scared of?

Thanks,
Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Smart group DB error - corrupted - want to delete it safely
March 30, 2011, 07:37:22 am
ps - i can't use the normal delete functionality because the SQL doesn't work.

incoming brainwave: i suppose I could just copy a working smartgroup criteria into this smart group and then delete it via the UI and sleep easy.  What do you think?
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Smart group DB error - corrupted - want to delete it safely
March 30, 2011, 08:27:53 pm
U'll also need to delete the right records from civicrm_saved_search

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Smart group DB error - corrupted - want to delete it safely
March 30, 2011, 09:53:20 pm
I know why it went wrong - there's a problem in Activity/BAO.Query.php

Change contact_b to civicrm_activity_target in the SQL & you'll be right

NB - this is broken in 3.3.6 & you might need to change the file too. The fix is either fully or partially in 3.4/4.0 but not being backported per last conversation with he who knows all.

(NB I say fully partially because either the fix or my backporting of it was incomplete so I had to fix it up again today on 3.3.6)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Smart group DB error - corrupted - want to delete it safely
April 06, 2011, 04:28:30 am
Thanks guys :) -> Eileen - you are pretty genius these days :)
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Smart group DB error - corrupted - want to delete it safely
April 06, 2011, 03:38:18 pm
I've just hit more than my fair share of problems!
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Smart group DB error - corrupted - want to delete it safely

This forum was archived on 2017-11-26.