* @return bool TRUE if FK is found
*/
public static function checkFKExists($table_name, $constraint_name) {
- $found = FALSE;
$config = CRM_Core_Config::singleton();
$dbUf = DB::parseDSN($config->dsn);
$query = "
$dao = CRM_Core_DAO::executeQuery($query, $params);
if ($dao->fetch()) {
- $found = TRUE;
+ return TRUE;
}
- return $found;
+ return FALSE;
}
/**
* @return bool
*/
public static function safeRemoveFK($table_name, $constraint_name) {
- $check = self::checkFKExists($table_name, $constraint_name);
-
- if ($check) {
+ if (self::checkFKExists($table_name, $constraint_name)) {
CRM_Core_DAO::executeQuery("ALTER TABLE {$table_name} DROP FOREIGN KEY {$constraint_name}", array());
return TRUE;
}
return TRUE;
}
+ /**
+ * @param string $table_name
+ * @param string $constraint_name
+ * @return bool
+ */
+ public static function checkFKExists($table_name, $constraint_name) {
+ return CRM_Core_BAO_SchemaHandler::checkFKExists($table_name, $constraint_name);
+ }
+
/**
* Add a column to a table if it doesn't already exist
*
if ($count = 1) {
CRM_Core_DAO::executeQuery("UPDATE civicrm_sms_provider SET domain_id = (SELECT id FROM civicrm_domain)");
}
- $check = CRM_Core_BAO_SchemaHandler::checkFKExists('civicrm_sms_provider', 'FK_civicrm_sms_provider_domain_id');
- if (!$check) {
+ if (!parent::checkFKExists('civicrm_sms_provider', 'FK_civicrm_sms_provider_domain_id')) {
CRM_Core_DAO::executeQuery("SET FOREIGN_KEY_CHECKS = 0;");
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_sms_provider`
ADD CONSTRAINT FK_civicrm_sms_provider_domain_id
* CRM-19986 fix schema differnces in civicrm_action_schedule
*/
public static function fixSchemaOnCiviCRMActionSchedule() {
- $check = CRM_Core_BAO_SchemaHandler::checkFKExists('civicrm_action_schedule', 'FK_civicrm_action_schedule_sms_template_id');
- if (!$check) {
+ if (!parent::checkFKExists('civicrm_action_schedule', 'FK_civicrm_action_schedule_sms_template_id')) {
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_action_schedule`
ADD CONSTRAINT FK_civicrm_action_schedule_sms_template_id
FOREIGN KEY (`sms_template_id`) REFERENCES `civicrm_msg_template`(`id`)