Skip to content

Commit

Permalink
Also add created_date & modified_date per discussion on pr
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Mar 2, 2021
1 parent 0d04d94 commit 89b4e41
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
44 changes: 43 additions & 1 deletion CRM/Contact/DAO/SavedSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Contact/SavedSearch.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:6a33a7d434232c0d9796934dcb29edf8)
* (GenCodeChecksum:25d5385ad222a7a7290fd18b3a27af8a)
*/

/**
Expand Down Expand Up @@ -107,6 +107,20 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
*/
public $expires_date;

/**
* When the search was created.
*
* @var timestamp
*/
public $created_date;

/**
* When the search was lase modified.
*
* @var timestamp
*/
public $modified_date;

/**
* Class constructor.
*/
Expand Down Expand Up @@ -318,6 +332,34 @@ public static function &fields() {
'localizable' => 0,
'add' => '5.36',
],
'created_date' => [
'name' => 'created_date',
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => ts('Created Date'),
'description' => ts('When the search was created.'),
'required' => TRUE,
'where' => 'civicrm_saved_search.created_date',
'default' => 'CURRENT_TIMESTAMP',
'table_name' => 'civicrm_saved_search',
'entity' => 'SavedSearch',
'bao' => 'CRM_Contact_BAO_SavedSearch',
'localizable' => 0,
'add' => '5.36',
],
'modified_date' => [
'name' => 'modified_date',
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => ts('Modified Date'),
'description' => ts('When the search was lase modified.'),
'required' => TRUE,
'where' => 'civicrm_saved_search.modified_date',
'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
'table_name' => 'civicrm_saved_search',
'entity' => 'SavedSearch',
'bao' => 'CRM_Contact_BAO_SavedSearch',
'localizable' => 0,
'add' => '5.36',
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
Expand Down
5 changes: 5 additions & 0 deletions CRM/Upgrade/Incremental/php/FiveThirtySix.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public function upgrade_5_36_alpha1(string $rev): void {
'civicrm_saved_search', 'modified_id', "int(10) unsigned DEFAULT NULL COMMENT 'FK to contact table.'");
$this->addTask('core-issue#2422 - Add expires_date to civicrm_saved_search', 'addColumn',
'civicrm_saved_search', 'expires_date', "timestamp NULL DEFAULT NULL COMMENT 'Optional date after which the search is not needed'");
$this->addTask('core-issue#2422 - Add created_date to civicrm_saved_search', 'addColumn',
'civicrm_saved_search', 'created_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the search was created.'");
$this->addTask('core-issue#2422 - Add modified_date to civicrm_saved_search', 'addColumn',
'civicrm_saved_search', 'modified_date', "timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When the search was last modified.'");

$this->addTask('core-issue#2422 - Add constraints to civicrm_saved_search', 'taskAddConstraints');

}
Expand Down
16 changes: 16 additions & 0 deletions xml/schema/Contact/SavedSearch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,20 @@
<comment>Optional date after which the search is not needed</comment>
<add>5.36</add>
</field>
<field>
<name>created_date</name>
<type>timestamp</type>
<comment>When the search was created.</comment>
<required>true</required>
<default>CURRENT_TIMESTAMP</default>
<add>5.36</add>
</field>
<field>
<name>modified_date</name>
<type>timestamp</type>
<comment>When the search was lase modified.</comment>
<required>true</required>
<default>CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP</default>
<add>5.36</add>
</field>
</table>

0 comments on commit 89b4e41

Please sign in to comment.