Make Note.privacy required
authorcolemanw <coleman@civicrm.org>
Sun, 17 Sep 2023 15:31:52 +0000 (11:31 -0400)
committercolemanw <coleman@civicrm.org>
Wed, 20 Sep 2023 11:30:24 +0000 (07:30 -0400)
CRM/Core/DAO/Note.php
CRM/Upgrade/Incremental/php/FiveSixtySeven.php
CRM/Upgrade/Incremental/sql/5.67.alpha1.mysql.tpl
xml/schema/Core/Note.xml

index 51aad849cc234465a30b066a61681c6bdd5c1018..dff8197327fdf65e1393b10ef2b095c85ef7bd85 100644 (file)
@@ -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',
index 9e764f02ed76e84da38463cfde68ad3eba33e309..429809a1a4716cb63cee91c3e5c397e0c81bdc6b 100644 (file)
@@ -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);
index 53f89523f4fc610fcaa828ff2e1f7ee944dc9d7c..4b47ee98b060feaef8877cd94576b6cc2b050e2a 100644 (file)
@@ -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;
 
index 574d62dfce3b65fbf0834fef75d41492f2195407..66ac6f2342df49ceff4d11ef9454016db775596a 100644 (file)
     <length>255</length>
     <comment>Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)</comment>
     <add>3.3</add>
+    <required>true</required>
+    <default>0</default>
     <html>
       <type>Select</type>
     </html>