Skip to content
Snippets Groups Projects
Commit 6386432c authored by Erik Hommel's avatar Erik Hommel
Browse files

fixed DAO/BAO to latest ideas

parent 1f9940d3
No related branches found
No related tags found
No related merge requests found
Showing
with 142 additions and 605 deletions
<?php
/**
* BAO Comparison for CiviRule Comparison
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_Civirules_BAO_Comparison extends CRM_Civirules_DAO_Comparison {
/**
* Function to get values
*
* @return array $result found rows with data
* @access public
* @static
*/
public static function getValues($params) {
$result = array();
$comparison = new CRM_Civirules_BAO_Comparison();
if (!empty($params)) {
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$comparison->$key = $value;
}
}
}
$comparison->find();
while ($comparison->fetch()) {
$row = array();
self::storeValues($comparison, $row);
$result[$row['id']] = $row;
}
return $result;
}
/**
* Function to add or update comparison
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
* @static
*/
public static function add($params) {
$result = array();
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a civirule comparison');
}
$comparison = new CRM_Civirules_BAO_Comparison();
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$comparison->$key = $value;
}
}
$comparison->save();
self::storeValues($comparison, $result);
return $result;
}
/**
* Function to delete a comparison with id
*
* @param int $comparisonId
* @throws Exception when comparison_id is empty
* @access public
* @static
*/
public static function deleteWithId($comparisonId) {
if (empty($comparisonId)) {
throw new Exception('comparison id can not be empty when attempting to delete a civirule comparison');
}
$comparison = new CRM_Civirules_BAO_Comparison();
$comparison->id = $comparisonId;
$comparison->delete();
return;
}
/**
* Function to disable a comparison
*
* @param int $comparisonId
* @throws Exception when comparisonId is empty
* @access public
* @static
*/
public static function disable($comparisonId) {
if (empty($comparisonId)) {
throw new Exception('comparison id can not be empty when attempting to disable a civirule comparison');
}
$comparison = new CRM_Civirules_BAO_Comparison();
$comparison->id = $comparisonId;
$comparison->find(true);
self::add(array('id' => $comparison->id, 'is_active' => 0));
}
/**
* Function to enable a comparison
*
* @param int $comparisonId
* @throws Exception when comparisonId is empty
* @access public
* @static
*/
public static function enable($comparisonId) {
if (empty($comparisonId)) {
throw new Exception('comparison id can not be empty when attempting to enable a civirule comparison');
}
$comparison = new CRM_Civirules_BAO_Comparison();
$comparison->id = $comparisonId;
$comparison->find(true);
self::add(array('id' => $comparison->id, 'is_active' => 1));
}
/**
* Function to retrieve the label of a comparison with comparisonId
*
* @param int $comparisonId
* @return string $comparison->label
* @access public
* @static
*/
public static function getComparisonLabelWithId($comparisonId) {
if (empty($comparisonId)) {
return '';
}
$comparison = new CRM_Civirules_BAO_Comparison();
$comparison->id = $comparisonId;
$comparison->find(true);
return $comparison->label;
}
}
\ No newline at end of file
<?php
/**
* BAO Condition for CiviRule Data Selector
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_Civirules_BAO_DataSelector extends CRM_Civirules_DAO_DataSelector {
/**
* Function to get values
*
* @return array $result found rows with data
* @access public
* @static
*/
public static function getValues($params) {
$result = array();
$dataSelector = new CRM_Civirules_BAO_DataSelector();
if (!empty($params)) {
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$dataSelector->$key = $value;
}
}
}
$dataSelector->find();
while ($dataSelector->fetch()) {
$row = array();
self::storeValues($dataSelector, $row);
$result[$row['id']] = $row;
}
return $result;
}
/**
* Function to add or update data selector
*
* @param array $params
* @return array $result
* @access public
* @throws Exception when params is empty
* @static
*/
public static function add($params) {
$result = array();
if (empty($params)) {
throw new Exception('Params can not be empty when adding or updating a civirule data selector');
}
$dataSelector = new CRM_Civirules_BAO_DataSelector();
$fields = self::fields();
foreach ($params as $key => $value) {
if (isset($fields[$key])) {
$dataSelector->$key = $value;
}
}
$dataSelector->save();
self::storeValues($dataSelector, $result);
return $result;
}
/**
* Function to delete a data selector with id
*
* @param int $dataSelectorId
* @throws Exception when dataSelectorId is empty
* @access public
* @static
*/
public static function deleteWithId($dataSelectorId) {
if (empty($dataSelectorId)) {
throw new Exception('data selector id can not be empty when attempting to delete a civirule data selector');
}
$dataSelector = new CRM_Civirules_BAO_DataSelector();
$dataSelector->id = $dataSelectorId;
$dataSelector->delete();
return;
}
/**
* Function to disable a data selector
*
* @param int $dataSelectorId
* @throws Exception when dataSelectorId is empty
* @access public
* @static
*/
public static function disable($dataSelectorId) {
if (empty($dataSelectorId)) {
throw new Exception('data selector id can not be empty when attempting to disable a civirule data selector');
}
$dataSelector = new CRM_Civirules_BAO_DataSelector();
$dataSelector->id = $dataSelectorId;
$dataSelector->find(true);
self::add(array('id' => $dataSelector->id, 'is_active' => 0));
}
/**
* Function to enable a data selector
*
* @param int $dataSelectorId
* @throws Exception when data_selector_id is empty
* @access public
* @static
*/
public static function enable($dataSelectorId) {
if (empty($dataSelectorId)) {
throw new Exception('data_selector_id can not be empty when attempting to enable a civirule data selector');
}
$dataSelector = new CRM_Civirules_BAO_DataSelector();
$dataSelector->id = $dataSelectorId;
$dataSelector->find(true);
self::add(array('id' => $dataSelector->id, 'is_active' => 1));
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ class CRM_Civirules_DAO_Action extends CRM_Core_DAO {
'name' => array(
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 64,
'maxlength' => 80,
),
'label' => array(
'name' => 'label',
......@@ -54,14 +54,35 @@ class CRM_Civirules_DAO_Action extends CRM_Core_DAO {
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 45,
) ,
'data_selector_id' => array(
'name' => 'data_selector_id',
'type' => CRM_Utils_Type::T_INT,
'action_params' => array(
'name' => 'action_params',
'type' => CRM_Utils_Type::T_BLOB,
),
'class_name' => array(
'name' => 'class_name',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 128,
),
'is_active' => array(
'name' => 'is_active',
'type' => CRM_Utils_Type::T_INT,
),
'created_date' => array(
'name' => 'created_date',
'type' => CRM_Utils_Type::T_DATE
),
'created_user_id' => array(
'name' => 'created_user_id',
'type' => CRM_Utils_Type::T_INT
),
'modified_date' => array(
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_DATE
),
'modified_user_id' => array(
'name' => 'modified_user_id',
'type' => CRM_Utils_Type::T_INT
),
);
}
return self::$_fields;
......@@ -81,8 +102,13 @@ class CRM_Civirules_DAO_Action extends CRM_Core_DAO {
'label' => 'label',
'api_entity' => 'api_entity',
'api_action' => 'api_action',
'data_selector_id' => 'data_selector_id',
'is_active' => 'is_active'
'action_params' => 'action_params',
'class_name' => 'class+name',
'is_active' => 'is_active',
'created_date' => 'created_date',
'created_user_id' => 'created_user_id',
'modified_date' => 'modified_date',
'modified_user_id' => 'modified_user_id',
);
}
return self::$_fieldKeys;
......
<?php
/**
* DAO Comparison for table civirule_comparison
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_Civirules_DAO_Comparison extends CRM_Core_DAO {
/**
* static instance to hold the field values
*
* @var array
* @static
*/
static $_fields = null;
static $_export = null;
/**
* empty definition for virtual function
*/
static function getTableName() {
return 'civirule_comparison';
}
/**
* returns all the column names of this table
*
* @access public
* @return array
*/
static function &fields() {
if (!(self::$_fields)) {
self::$_fields = array(
'id' => array(
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'required' => true
) ,
'label' => array(
'name' => 'label',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 45,
),
'operator' => array(
'name' => 'operator',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 45,
)
);
}
return self::$_fields;
}
/**
* Returns an array containing, for each field, the array key used for that
* field in self::$_fields.
*
* @access public
* @return array
*/
static function &fieldKeys() {
if (!(self::$_fieldKeys)) {
self::$_fieldKeys = array(
'id' => 'id',
'label' => 'label',
'operator' => 'operator'
);
}
return self::$_fieldKeys;
}
/**
* returns the list of fields that can be exported
*
* @access public
* return array
* @static
*/
static function &export($prefix = false)
{
if (!(self::$_export)) {
self::$_export = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
self::$_export['activity'] = & $fields[$name];
} else {
self::$_export[$name] = & $fields[$name];
}
}
}
}
return self::$_export;
}
}
\ No newline at end of file
......@@ -37,27 +37,38 @@ class CRM_Civirules_DAO_Condition extends CRM_Core_DAO {
'name' => array(
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 64,
'maxlength' => 80,
),
'label' => array(
'name' => 'label',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 128,
),
'function_name' => array(
'name' => 'function_name',
'class_name' => array(
'name' => 'class_name',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 256,
),
'civicrm_form_class' => array(
'name' => 'civicrm_form_class',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 256,
'maxlength' => 128,
),
'is_active' => array(
'name' => 'is_active',
'type' => CRM_Utils_Type::T_INT,
)
),
'created_date' => array(
'name' => 'created_date',
'type' => CRM_Utils_Type::T_DATE
),
'created_user_id' => array(
'name' => 'created_user_id',
'type' => CRM_Utils_Type::T_INT
),
'modified_date' => array(
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_DATE
),
'modified_user_id' => array(
'name' => 'modified_user_id',
'type' => CRM_Utils_Type::T_INT
),
);
}
return self::$_fields;
......@@ -75,9 +86,12 @@ class CRM_Civirules_DAO_Condition extends CRM_Core_DAO {
'id' => 'id',
'name' => 'name',
'label' => 'label',
'function_name' => 'function_name',
'civicrm_form_class' => 'civicrm_form_class',
'is_active' => 'is_active'
'class_name' => 'class_name',
'is_active' => 'is_active',
'created_date' => 'created_date',
'created_user_id' => 'created_user_id',
'modified_date' => 'modified_date',
'modified_user_id' => 'modified_user_id',
);
}
return self::$_fieldKeys;
......
<?php
/**
* DAO DataSelector for table civirule_data_selector
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @license http://www.gnu.org/licenses/agpl-3.0.html
*/
class CRM_Civirules_DAO_DataSelector extends CRM_Core_DAO {
/**
* static instance to hold the field values
*
* @var array
* @static
*/
static $_fields = null;
static $_export = null;
/**
* empty definition for virtual function
*/
static function getTableName() {
return 'civirule_data_selector';
}
/**
* returns all the column names of this table
*
* @access public
* @return array
*/
static function &fields() {
if (!(self::$_fields)) {
self::$_fields = array(
'id' => array(
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'required' => true
) ,
'label' => array(
'name' => 'label',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 64,
),
'description' => array(
'name' => 'description',
'type' => CRM_Utils_Type::T_TEXT,
),
'entity' => array(
'name' => 'entity',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 64,
),
'column_name' => array(
'name' => 'column_name',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 128,
),
'function_name' => array(
'name' => 'function_name',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 256,
),
'is_active' => array(
'name' => 'is_active',
'type' => CRM_Utils_Type::T_INT,
)
);
}
return self::$_fields;
}
/**
* Returns an array containing, for each field, the array key used for that
* field in self::$_fields.
*
* @access public
* @return array
*/
static function &fieldKeys() {
if (!(self::$_fieldKeys)) {
self::$_fieldKeys = array(
'id' => 'id',
'label' => 'label',
'description' => 'description',
'entity' => 'entity',
'column_name' => 'column_name',
'function_name' => 'function_name',
'is_active' => 'is_active'
);
}
return self::$_fieldKeys;
}
/**
* returns the list of fields that can be exported
*
* @access public
* return array
* @static
*/
static function &export($prefix = false)
{
if (!(self::$_export)) {
self::$_export = array();
$fields = self::fields();
foreach($fields as $name => $field) {
if (CRM_Utils_Array::value('export', $field)) {
if ($prefix) {
self::$_export['activity'] = & $fields[$name];
} else {
self::$_export[$name] = & $fields[$name];
}
}
}
}
return self::$_export;
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ class CRM_Civirules_DAO_Event extends CRM_Core_DAO {
'name' => array(
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 64,
'maxlength' => 80,
),
'label' => array(
'name' => 'label',
......@@ -47,20 +47,38 @@ class CRM_Civirules_DAO_Event extends CRM_Core_DAO {
'entity' => array(
'name' => 'entity',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 64,
'maxlength' => 45,
),
'action' => array(
'name' => 'action',
'type' => CRM_Utils_Type::T_STRING
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 45
),
'method' => array(
'name' => 'method',
'type' => CRM_Utils_Type::T_STRING
'class_name' => array(
'name' => 'class_name',
'type' => CRM_Utils_Type::T_STRING,
maxlength => 128
),
'is_active' => array(
'name' => 'is_active',
'type' => CRM_Utils_Type::T_INT,
)
),
'created_date' => array(
'name' => 'created_date',
'type' => CRM_Utils_Type::T_DATE
),
'created_user_id' => array(
'name' => 'created_user_id',
'type' => CRM_Utils_Type::T_INT
),
'modified_date' => array(
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_DATE
),
'modified_user_id' => array(
'name' => 'modified_user_id',
'type' => CRM_Utils_Type::T_INT
),
);
}
return self::$_fields;
......@@ -80,8 +98,12 @@ class CRM_Civirules_DAO_Event extends CRM_Core_DAO {
'label' => 'label',
'entity' => 'entity',
'action' => 'action',
'method' => 'method',
'is_active' => 'is_active'
'class_name' => 'class_name',
'is_active' => 'is_active',
'created_date' => 'created_date',
'created_user_id' => 'created_user_id',
'modified_date' => 'modified_date',
'modified_user_id' => 'modified_user_id',
);
}
return self::$_fieldKeys;
......
......@@ -37,7 +37,7 @@ class CRM_Civirules_DAO_Rule extends CRM_Core_DAO {
'name' => array(
'name' => 'name',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 64,
'maxlength' => 80,
) ,
'label' => array(
'name' => 'label',
......@@ -54,12 +54,20 @@ class CRM_Civirules_DAO_Rule extends CRM_Core_DAO {
),
'created_date' => array(
'name' => 'created_date',
'type' => CRM_Utils_Type::T_DATE,
'type' => CRM_Utils_Type::T_DATE
),
'created_contact_id' => array(
'name' => 'created_contact_id',
'created_user_id' => array(
'name' => 'created_user_id',
'type' => CRM_Utils_Type::T_INT
)
),
'modified_date' => array(
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_DATE
),
'modified_user_id' => array(
'name' => 'modified_user_id',
'type' => CRM_Utils_Type::T_INT
),
);
}
return self::$_fields;
......@@ -80,7 +88,9 @@ class CRM_Civirules_DAO_Rule extends CRM_Core_DAO {
'event_id' => 'event_id',
'is_active' => 'is_active',
'created_date' => 'created_date',
'created_contact_id' => 'created_contact_id'
'created_user_id' => 'created_user_id',
'modified_date' => 'modified_date',
'modified_user_id' => 'modified_user_id',
);
}
return self::$_fieldKeys;
......
......@@ -42,20 +42,10 @@ class CRM_Civirules_DAO_RuleAction extends CRM_Core_DAO {
'name' => 'action_id',
'type' => CRM_Utils_Type::T_INT
),
'action_value' => array(
'name' => 'action_value',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 128,
),
'extra_params' => array(
'name' => 'extra_params',
'action_params' => array(
'name' => 'action_params',
'type' => CRM_Utils_Type::T_BLOB
),
'civicrm_form_class' => array(
'name' => 'civicrm_form_class',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 256
),
'is_active' => array(
'name' => 'is_active',
'type' => CRM_Utils_Type::T_INT,
......@@ -77,9 +67,7 @@ class CRM_Civirules_DAO_RuleAction extends CRM_Core_DAO {
'id' => 'id',
'rule_id' => 'rule_id',
'action_id' => 'action_id',
'action_value' => 'action_value',
'extra_params' => 'extra_params',
'civicrm_form_class' => 'civicrm_form_class',
'action_params' => 'action_params',
'is_active' => 'is_active'
);
}
......
......@@ -38,22 +38,13 @@ class CRM_Civirules_DAO_RuleCondition extends CRM_Core_DAO {
'name' => 'rule_id',
'type' => CRM_Utils_Type::T_INT
),
'condition_id' => array(
'name' => 'condition_id',
'type' => CRM_Utils_Type::T_INT
),
'condition_operator' => array(
'name' => 'condition_operator',
'condition_link' => array(
'name' => 'condition_link',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 25,
'maxlength' => 3,
),
'condition_value' => array(
'name' => 'condition_value',
'type' => CRM_Utils_Type::T_STRING,
'maxlength' => 128,
),
'comparison_id' => array(
'name' => 'comparison_id',
'condition_id' => array(
'name' => 'condition_id',
'type' => CRM_Utils_Type::T_INT
),
'is_active' => array(
......@@ -76,10 +67,8 @@ class CRM_Civirules_DAO_RuleCondition extends CRM_Core_DAO {
self::$_fieldKeys = array(
'id' => 'id',
'rule_id' => 'rule_id',
'condition_link' => 'condition_link',
'condition_id' => 'condition_id',
'condition_operator' => 'condition_operator',
'condition_value' => 'condition_value',
'comparison_id' => 'comparison_id',
'is_active' => 'is_active'
);
}
......
......@@ -11,44 +11,11 @@ class CRM_Civirules_Upgrader extends CRM_Civirules_Upgrader_Base {
* sequence as there will be dependencies in the foreign keys
*/
public function install() {
$this->executeSqlFile('sql/createCiviruleComparison.sql');
$this->executeSqlFile('sql/createCiviruleAction.sql');
$this->executeSqlFile('sql/createCiviruleCondition.sql');
$this->executeSqlFile('sql/createCiviruleDataSelector.sql');
$this->executeSqlFile('sql/createCiviruleEvent.sql');
$this->executeSqlFile('sql/createCiviruleRule.sql');
$this->executeSqlFile('sql/createCiviruleAction.sql');
$this->executeSqlFile('sql/createCiviruleRuleAction.sql');
$this->executeSqlFile('sql/createCiviruleRuleCondition.sql');
}
/**
* Upgrade 1001 - add columns api_action and api_entity to civirule_action
*/
public function upgrade_1001() {
$this->ctx->log->info('Applying update 1001 (add columns api_action and api_entity to civirule_action)');
if (CRM_Core_DAO::checkTableExists('civirule_action')) {
if (!CRM_Core_DAO::checkFieldExists('civirule_action', 'api_entity')) {
CRM_Core_DAO::executeQuery('ALTER TABLE civirule_action ADD COLUMN api_entity VARCHAR(45) AFTER label');
}
if (!CRM_Core_DAO::checkFieldExists('civirule_action', 'api_action')) {
CRM_Core_DAO::executeQuery('ALTER TABLE civirule_action ADD COLUMN api_action VARCHAR(45) AFTER api_entity');
}
}
return TRUE;
}
/**
* Upgrade 1002 - drop column comparison_id from civirule_rule_action
*/
public function upgrade_1002() {
$this->ctx->log->info('Applying update 1002 (drop column comparison_id from civirule_rule_action)');
if (CRM_Core_DAO::checkTableExists('civirule_rule_action')) {
if (CRM_Core_DAO::checkFieldExists('civirule_rule_action', 'comparison_id')) {
CRM_Core_DAO::executeQuery('ALTER TABLE civirule_rule_action DROP FOREIGN KEY fk_ra_comparison');
CRM_Core_DAO::executeQuery('ALTER TABLE civirule_rule_action DROP INDEX fk_ra_comparison_idx');
CRM_Core_DAO::executeQuery('ALTER TABLE civirule_rule_action DROP COLUMN comparison_id');
}
}
return TRUE;
}
}
\ No newline at end of file
CREATE TABLE IF NOT EXISTS civirule_action (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(64) NULL,
name VARCHAR(80) NULL,
label VARCHAR(128) NULL,
api_entity VARCHAR(45) NULL,
api_action VARCHAR(45) NULL,
data_selector_id INT UNSIGNED NULL,
action_params BLOB NULL,
class_name VARCHAR(128) NULL,
is_active TINYINT NULL DEFAULT 1,
created_date DATE NULL,
created_user_id INT NULL,
modified_date DATE NULL,
modified_user_id INT NULL,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC),
INDEX fk_data_selector_idx (data_selector_id ASC),
CONSTRAINT fk_data_selector
FOREIGN KEY (data_selector_id)
REFERENCES civirule_data_selector (id)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
UNIQUE INDEX id_UNIQUE (id ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci
CREATE TABLE IF NOT EXISTS civirule_comparison (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
label VARCHAR(45) NULL,
operator VARCHAR(45) NULL,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci
CREATE TABLE IF NOT EXISTS civirule_condition (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(64) NULL,
name VARCHAR(80) NULL,
label VARCHAR(128) NULL,
function_name VARCHAR(256) NULL,
civicrm_form_class VARCHAR(256) NULL,
class_name VARCHAR(128) NULL,
is_active TINYINT NULL DEFAULT 1,
created_date DATE NULL,
created_user_id INT NULL,
modified_date DATE NULL,
modified_user_id INT NULL,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC))
ENGINE = InnoDB
......
CREATE TABLE IF NOT EXISTS civirule_data_selector (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
entity VARCHAR(64) NULL,
column_name VARCHAR(128) NULL,
label VARCHAR(68) NULL,
description TEXT NULL,
is_active TINYINT NULL DEFAULT 1,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci
CREATE TABLE IF NOT EXISTS civirule_event (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(64) NULL,
name VARCHAR(80) NULL,
label VARCHAR(128) NULL,
entity VARCHAR(68) NULL,
entity VARCHAR(45) NULL,
action VARCHAR(45) NULL,
method VARCHAR(45) NULL,
class_name VARCHAR(128) NULL,
is_active TINYINT NULL DEFAULT 1,
created_date DATE NULL,
created_user_id INT NULL,
modified_date DATE NULL,
modified_user_id INT NULL,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC))
ENGINE = InnoDB
......
CREATE TABLE IF NOT EXISTS civirule_rule (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(64) NULL,
name VARCHAR(80) NULL,
label VARCHAR(128) NULL,
event_id INT UNSIGNED NULL,
is_active TINYINT NULL DEFAULT 1,
created_date DATE NULL,
created_contact_id INT NULL,
modified_date DATE NULL,
modified_contact_id INT NULL,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC),
INDEX fk_rule_event_idx (event_id ASC),
......
......@@ -2,9 +2,7 @@ CREATE TABLE IF NOT EXISTS civirule_rule_action (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
rule_id INT UNSIGNED NULL,
action_id INT UNSIGNED NULL,
action_value VARCHAR(128) NULL,
extra_params BLOB NULL,
civicrm_form_class VARCHAR(256) NULL,
action_params BLOB NULL,
is_active TINYINT NULL DEFAULT 1,
UNIQUE INDEX id_UNIQUE (id ASC),
INDEX fk_ra_rule_idx (rule_id ASC),
......
CREATE TABLE IF NOT EXISTS civirule_rule_condition (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
rule_id INT UNSIGNED NULL,
condition_link VARCHAR(3) NULL,
condition_id INT UNSIGNED NULL,
condition_operator VARCHAR(25) NULL,
condition_value VARCHAR(128) NULL,
comparison_id INT UNSIGNED NULL,
is_active TINYINT NULL DEFAULT 1,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC),
INDEX fk_rc_rule_idx (rule_id ASC),
INDEX fk_rc_condition_idx (condition_id ASC),
INDEX fk_rc_comparison_idx (comparison_id ASC),
CONSTRAINT fk_rc_rule
FOREIGN KEY (rule_id)
REFERENCES civirule_rule (id)
......@@ -20,11 +17,6 @@ CREATE TABLE IF NOT EXISTS civirule_rule_condition (
FOREIGN KEY (condition_id)
REFERENCES civirule_condition (id)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT fk_rc_comparison
FOREIGN KEY (comparison_id)
REFERENCES civirule_comparison (id)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment