From 49974a7f7a8541fe4f1023824d49d18170b50c6e Mon Sep 17 00:00:00 2001 From: colemanw Date: Sun, 17 Sep 2023 11:31:52 -0400 Subject: [PATCH] Make Note.privacy required --- CRM/Core/DAO/Note.php | 6 ++++-- CRM/Upgrade/Incremental/php/FiveSixtySeven.php | 1 + CRM/Upgrade/Incremental/sql/5.67.alpha1.mysql.tpl | 2 ++ xml/schema/Core/Note.xml | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CRM/Core/DAO/Note.php b/CRM/Core/DAO/Note.php index 51aad849cc..dff8197327 100644 --- a/CRM/Core/DAO/Note.php +++ b/CRM/Core/DAO/Note.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/Note.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:aa7f2dd9a225bafdc5c551d869dfae8a) + * (GenCodeChecksum:c04c2c1404af638e1adf973fe845d0ac) */ /** @@ -121,7 +121,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO { /** * Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK) * - * @var string|null + * @var string * (SQL type: varchar(255)) * Note that values will be retrieved from the database as a string. */ @@ -395,6 +395,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO { 'type' => CRM_Utils_Type::T_STRING, 'title' => ts('Privacy'), 'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'), + 'required' => TRUE, 'maxlength' => 255, 'size' => CRM_Utils_Type::HUGE, 'usage' => [ @@ -404,6 +405,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO { 'token' => FALSE, ], 'where' => 'civicrm_note.privacy', + 'default' => '0', 'table_name' => 'civicrm_note', 'entity' => 'Note', 'bao' => 'CRM_Core_BAO_Note', diff --git a/CRM/Upgrade/Incremental/php/FiveSixtySeven.php b/CRM/Upgrade/Incremental/php/FiveSixtySeven.php index 9e764f02ed..429809a1a4 100644 --- a/CRM/Upgrade/Incremental/php/FiveSixtySeven.php +++ b/CRM/Upgrade/Incremental/php/FiveSixtySeven.php @@ -29,6 +29,7 @@ class CRM_Upgrade_Incremental_php_FiveSixtySeven extends CRM_Upgrade_Incremental */ public function upgrade_5_67_alpha1($rev): void { $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); + $this->addTask('Make Note.privacy required', 'alterColumn', 'civicrm_note', 'privacy', "varchar(255) NOT NULL DEFAULT 0 COMMENT 'Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'"); $this->addTask('Make EntityFile.entity_table required', 'alterColumn', 'civicrm_entity_file', 'entity_table', "varchar(64) NOT NULL COMMENT 'physical tablename for entity being joined to file, e.g. civicrm_contact'"); $this->addExtensionTask('Enable Authx extension', ['authx'], 1101); $this->addExtensionTask('Enable Afform extension', ['org.civicrm.afform'], 1102); diff --git a/CRM/Upgrade/Incremental/sql/5.67.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.67.alpha1.mysql.tpl index 53f89523f4..4b47ee98b0 100644 --- a/CRM/Upgrade/Incremental/sql/5.67.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/5.67.alpha1.mysql.tpl @@ -1,5 +1,7 @@ {* file to handle db changes in 5.67.alpha1 during upgrade *} +UPDATE civicrm_note SET privacy = 0 WHERE privacy IS NULL; + {* NULL values would be nonsensical and useless - no reason to keep them *} DELETE FROM civicrm_entity_file WHERE entity_table IS NULL; diff --git a/xml/schema/Core/Note.xml b/xml/schema/Core/Note.xml index 574d62dfce..66ac6f2342 100644 --- a/xml/schema/Core/Note.xml +++ b/xml/schema/Core/Note.xml @@ -153,6 +153,8 @@ 255 Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK) 3.3 + true + 0 Select -- 2.25.1