Esempio n. 1
0
 /**
  * Test to see if we can drop foreign key
  *
  * @dataProvider foreignKeyTests
  */
 public function testSafeDropForeignKey($tableName, $key)
 {
     if ($key == 'FK_civicrm_mailing_recipients_id') {
         $this->assertFalse(CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_mailing_recipients', $key));
     } else {
         $this->assertTrue(CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_mailing_recipients', $key));
     }
 }
Esempio n. 2
0
 /**
  * CRM-18345 Don't delete mailing data on email/phone deletion
  * Implemented here in CRM-18526
  *
  * @param \CRM_Queue_TaskContext $ctx
  *
  * @return bool
  */
 public static function upgradeMailingFKs(CRM_Queue_TaskContext $ctx)
 {
     // Safely drop the foreign keys
     CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_mailing_event_queue', 'FK_civicrm_mailing_event_queue_email_id');
     CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_mailing_event_queue', 'FK_civicrm_mailing_event_queue_phone_id');
     CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_mailing_recipients', 'FK_civicrm_mailing_recipients_email_id');
     CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_mailing_recipients', 'FK_civicrm_mailing_recipients_phone_id');
     // Set up the new foreign keys
     CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS = 0;");
     CRM_Core_DAO::executeQuery("\n      ALTER TABLE `civicrm_mailing_event_queue`\n        ADD CONSTRAINT `FK_civicrm_mailing_event_queue_email_id`\n        FOREIGN KEY (`email_id`)\n        REFERENCES `civicrm_email`(`id`)\n        ON DELETE SET NULL\n        ON UPDATE RESTRICT;\n    ");
     CRM_Core_DAO::executeQuery("\n      ALTER TABLE `civicrm_mailing_event_queue`\n        ADD CONSTRAINT `FK_civicrm_mailing_event_queue_phone_id`\n        FOREIGN KEY (`phone_id`)\n        REFERENCES `civicrm_phone`(`id`)\n        ON DELETE SET NULL\n        ON UPDATE RESTRICT;\n    ");
     CRM_Core_DAO::executeQuery("\n      ALTER TABLE `civicrm_mailing_recipients`\n        ADD CONSTRAINT `FK_civicrm_mailing_recipients_email_id`\n        FOREIGN KEY (`email_id`)\n        REFERENCES `civicrm_email`(`id`)\n        ON DELETE SET NULL\n        ON UPDATE RESTRICT;\n    ");
     CRM_Core_DAO::executeQuery("\n      ALTER TABLE `civicrm_mailing_recipients`\n        ADD CONSTRAINT `FK_civicrm_mailing_recipients_phone_id`\n        FOREIGN KEY (`phone_id`)\n        REFERENCES `civicrm_phone`(`id`)\n        ON DELETE SET NULL\n        ON UPDATE RESTRICT;\n    ");
     CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS = 1;");
     return TRUE;
 }