Schema - Fix boolean fields in 'Member'
authorMonish Deb <monish.deb@jmaconsulting.biz>
Fri, 8 Apr 2022 01:12:17 +0000 (18:12 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 8 Apr 2022 01:12:17 +0000 (18:12 -0700)
CRM/Member/DAO/Membership.php
CRM/Member/DAO/MembershipBlock.php
CRM/Member/DAO/MembershipStatus.php
CRM/Upgrade/Incremental/php/FiveFortyNine/Member.bool.php [new file with mode: 0644]
tests/phpunit/CRM/Member/BAO/MembershipTest.php
xml/schema/Member/Membership.xml
xml/schema/Member/MembershipBlock.xml
xml/schema/Member/MembershipStatus.xml

index 94bcb0f9b07e0a5be76d49e9fcf50f9e970f40b1..dd6995cd3011f851dc9a01fa91ce19eff1f44555 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Member/Membership.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:0619aa3946bcadcab1919672c9ecf35a)
+ * (GenCodeChecksum:1668d4d8a9f2e1686bf9f5b6ea1c55dc)
  */
 
 /**
@@ -123,7 +123,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
   /**
    * Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -157,14 +157,14 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
   public $max_related;
 
   /**
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
   public $is_test;
 
   /**
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -421,10 +421,12 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Status Override'),
           'description' => ts('Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.'),
+          'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_membership.is_override',
           'headerPattern' => '/override$/i',
           'export' => TRUE,
+          'default' => '0',
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
           'bao' => 'CRM_Member_BAO_Membership',
@@ -491,6 +493,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'name' => 'is_test',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Test'),
+          'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_membership.is_test',
           'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
@@ -509,6 +512,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'name' => 'is_pay_later',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Pay Later'),
+          'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_membership.is_pay_later',
           'headerPattern' => '/(is.)?(pay(.)?later)$/i',
index a8fdf704d6034c326b3b9af1480a00170408d719..d51f917e0422e5a2576c37504590be931b88f567 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Member/MembershipBlock.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:8e0e93f6f480d279cbf4ac53db86a8f3)
+ * (GenCodeChecksum:b8779f341fdb53bc75c0928fea73f06f)
  */
 
 /**
@@ -79,7 +79,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
   /**
    * Display minimum membership fee
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -88,7 +88,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
   /**
    * Should membership transactions be processed separately
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -133,7 +133,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
   /**
    * Is membership sign up optional
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -142,7 +142,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
   /**
    * Is this membership_block enabled
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -274,6 +274,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Membership Block Display Minimum Fee'),
           'description' => ts('Display minimum membership fee'),
+          'required' => TRUE,
           'where' => 'civicrm_membership_block.display_min_fee',
           'default' => '1',
           'table_name' => 'civicrm_membership_block',
@@ -287,6 +288,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Membership Block Is Separate Payment'),
           'description' => ts('Should membership transactions be processed separately'),
+          'required' => TRUE,
           'where' => 'civicrm_membership_block.is_separate_payment',
           'default' => '1',
           'table_name' => 'civicrm_membership_block',
@@ -352,6 +354,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Required'),
           'description' => ts('Is membership sign up optional'),
+          'required' => TRUE,
           'where' => 'civicrm_membership_block.is_required',
           'default' => '0',
           'table_name' => 'civicrm_membership_block',
@@ -365,6 +368,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Active'),
           'description' => ts('Is this membership_block enabled'),
+          'required' => TRUE,
           'where' => 'civicrm_membership_block.is_active',
           'default' => '1',
           'table_name' => 'civicrm_membership_block',
index 764946fbb835158ee166b2365434797b508eacf4..0b4d58277acb1d5f4b6ab4c5eb8990c43c1c8c1a 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Member/MembershipStatus.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:5c4442b352b42ed23368f5dbb0bc0531)
+ * (GenCodeChecksum:baf51df46a12becf1b8ed3f8a25e2237)
  */
 
 /**
@@ -122,7 +122,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
   /**
    * Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -131,7 +131,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
   /**
    * Is this status for admin/manual assignment only.
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -147,7 +147,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
   /**
    * Assign this status to a membership record if no other status match is found.
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -156,7 +156,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
   /**
    * Is this membership_status enabled.
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -165,7 +165,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
   /**
    * Is this membership_status reserved.
    *
-   * @var bool|string|null
+   * @var bool|string
    *   (SQL type: tinyint)
    *   Note that values will be retrieved from the database as a string.
    */
@@ -367,7 +367,9 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Current Membership?'),
           'description' => ts('Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).'),
+          'required' => TRUE,
           'where' => 'civicrm_membership_status.is_current_member',
+          'default' => '0',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -379,7 +381,9 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Administrator Only?'),
           'description' => ts('Is this status for admin/manual assignment only.'),
+          'required' => TRUE,
           'where' => 'civicrm_membership_status.is_admin',
+          'default' => '0',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -405,7 +409,9 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Default Status?'),
           'description' => ts('Assign this status to a membership record if no other status match is found.'),
+          'required' => TRUE,
           'where' => 'civicrm_membership_status.is_default',
+          'default' => '0',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -420,6 +426,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Active'),
           'description' => ts('Is this membership_status enabled.'),
+          'required' => TRUE,
           'where' => 'civicrm_membership_status.is_active',
           'default' => '1',
           'table_name' => 'civicrm_membership_status',
@@ -436,6 +443,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Reserved'),
           'description' => ts('Is this membership_status reserved.'),
+          'required' => TRUE,
           'where' => 'civicrm_membership_status.is_reserved',
           'default' => '0',
           'table_name' => 'civicrm_membership_status',
diff --git a/CRM/Upgrade/Incremental/php/FiveFortyNine/Member.bool.php b/CRM/Upgrade/Incremental/php/FiveFortyNine/Member.bool.php
new file mode 100644 (file)
index 0000000..f410b90
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+return [
+  'civicrm_membership' => [
+    'is_override' => "DEFAULT 0 COMMENT 'Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.'",
+    'is_test' => "DEFAULT 0",
+    'is_pay_later' => "DEFAULT 0",
+  ],
+  'civicrm_membership_block' => [
+    'display_min_fee' => "DEFAULT 1 COMMENT 'Display minimum membership fee'",
+    'is_separate_payment' => "DEFAULT 1 COMMENT 'Should membership transactions be processed separately'",
+    'is_required' => "DEFAULT 0 COMMENT 'Is membership sign up optional'",
+    'is_active' => "DEFAULT 1 COMMENT 'Is this membership_block enabled'",
+  ],
+  'civicrm_membership_status' => [
+    'is_current_member' => "DEFAULT 0 COMMENT 'Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).'",
+    'is_admin' => "DEFAULT 0 COMMENT 'Is this status for admin/manual assignment only.'",
+    'is_default' => "DEFAULT 0 COMMENT 'Assign this status to a membership record if no other status match is found.'",
+    'is_active' => "DEFAULT 1 COMMENT 'Is this membership_status enabled.'",
+    'is_reserved' => "DEFAULT 0 COMMENT 'Is this membership_status reserved.'",
+  ],
+];
index 8df9749e31f36b9bcacb12cba6445c29871053d5..616998c9c0b50ccfdb2b18e9a51d507192a7b39c 100644 (file)
@@ -622,7 +622,6 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
     ])['values'][0];
 
     $this->assertEquals($createdMembershipID, $membershipAfterProcess['id']);
-    $this->assertArrayNotHasKey('is_override', $membershipAfterProcess);
     $this->assertArrayNotHasKey('status_override_end_date', $membershipAfterProcess);
   }
 
@@ -654,7 +653,6 @@ class CRM_Member_BAO_MembershipTest extends CiviUnitTestCase {
     ])['values'][0];
 
     $this->assertEquals($createdMembershipID, $membershipAfterProcess['id']);
-    $this->assertArrayNotHasKey('is_override', $membershipAfterProcess);
     $this->assertArrayNotHasKey('status_override_end_date', $membershipAfterProcess);
   }
 
index 3ed25d6adc84e82409eac9ef4d71ee979a7a7552..f2ed08d0ea1e4027454ac1dd1197fdf5ee6a07d8 100644 (file)
     <html>
       <type>CheckBox</type>
     </html>
+    <default>0</default>
+    <required>true</required>
     <add>1.5</add>
   </field>
   <field>
     <uniqueName>member_is_test</uniqueName>
     <type>boolean</type>
     <default>0</default>
+    <required>true</required>
     <import>true</import>
     <headerPattern>/(is.)?test(.member(ship)?)?/i</headerPattern>
     <html>
     <title>Is Pay Later</title>
     <type>boolean</type>
     <default>0</default>
+    <required>true</required>
     <import>true</import>
     <headerPattern>/(is.)?(pay(.)?later)$/i</headerPattern>
     <add>2.1</add>
index a31e85e413cccecddaf8e798f57b1561eae89be9..fc879463537f84e010957cb16fd9adf4c6e37dc1 100644 (file)
@@ -80,6 +80,7 @@
     <title>Membership Block Display Minimum Fee</title>
     <type>boolean</type>
     <default>1</default>
+    <required>true</required>
     <comment>Display minimum membership fee</comment>
     <add>1.5</add>
   </field>
@@ -88,6 +89,7 @@
     <title>Membership Block Is Separate Payment</title>
     <type>boolean</type>
     <default>1</default>
+    <required>true</required>
     <comment>Should membership transactions be processed separately</comment>
     <add>1.5</add>
   </field>
     <title>Is Required</title>
     <type>boolean</type>
     <default>0</default>
+    <required>true</required>
     <comment>Is membership sign up optional</comment>
     <add>1.5</add>
   </field>
     <title>Is Active</title>
     <type>boolean</type>
     <default>1</default>
+    <required>true</required>
     <comment>Is this membership_block enabled</comment>
     <add>1.5</add>
   </field>
index 2bf75d8ad6d792b9ad2eefc1f78bc884f0c923e3..782ed48bac14cf73681ffe37f38a2213bde8be01 100644 (file)
     <name>is_current_member</name>
     <title>Current Membership?</title>
     <type>boolean</type>
+    <default>0</default>
+    <required>true</required>
     <comment>Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).</comment>
     <add>1.5</add>
   </field>
     <html>
       <type>CheckBox</type>
     </html>
+    <default>0</default>
+    <required>true</required>
     <add>1.5</add>
   </field>
   <field>
     <name>is_default</name>
     <title>Default Status?</title>
     <type>boolean</type>
+    <default>0</default>
+    <required>true</required>
     <html>
       <type>CheckBox</type>
     </html>
     <title>Is Active</title>
     <type>boolean</type>
     <default>1</default>
+    <required>true</required>
     <html>
       <type>CheckBox</type>
     </html>
     <title>Is Reserved</title>
     <type>boolean</type>
     <default>0</default>
+    <required>true</required>
     <html>
       <type>CheckBox</type>
     </html>