[REF] Implement required fields database changes that have occured during 5.27.alpha1...
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 2 Jun 2020 09:31:56 +0000 (19:31 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 2 Jun 2020 11:03:46 +0000 (21:03 +1000)
CRM/Upgrade/Incremental/php/FiveTwentySeven.php

index b78bbb34225ac51dc0ab6f2fbe3245dfa83d097b..5ee49a29ce376850c1d4532da3cdde72a350c131 100644 (file)
@@ -62,7 +62,40 @@ class CRM_Upgrade_Incremental_php_FiveTwentySeven extends CRM_Upgrade_Incrementa
     $this->addTask('Add serialize column to civicrm_custom_field', 'addColumn',
       'civicrm_custom_field', 'serialize', "int unsigned DEFAULT NULL COMMENT 'Serialization method - a non-null value indicates a multi-valued field.'"
     );
+    $this->addTask('Make the label field required on price field value', 'priceFieldValueLabelRequired');
+    $this->addTask('Make the name field required on civicrm_membership_type', 'nameMembershipTypeRequired');
+    $this->addTask('Rebuild Multilingal Schema', 'rebuildMultilingalSchema', '5.27.alpha1');
     $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
   }
 
+  public function priceFieldValueLabelRequired($ctx) {
+    $domain = new CRM_Core_DAO_Domain();
+    $domain->find(TRUE);
+    if ($domain->locales) {
+      $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
+      foreach ($locales as $locale) {
+        CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_price_field_value CHANGE `label_{$locale}` `label_{$locale}` varchar(255) NOT NULL   COMMENT 'Price field option label'", [], TRUE, NULL, FALSE, FALSE);
+      }
+    }
+    else {
+      CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_price_field_value CHANGE `label` `label` varchar(255) NOT NULL   COMMENT 'Price field option label'", [], TRUE, NULL, FALSE, FALSE);
+    }
+    return TRUE;
+  }
+
+  public function nameMembershipTypeRequired($ctx) {
+    $domain = new CRM_Core_DAO_Domain();
+    $domain->find(TRUE);
+    if ($domain->locales) {
+      $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
+      foreach ($locales as $locale) {
+        CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_membership_type CHANGE `name_{$locale}` `name_{$locale}` varchar(128) NOT NULL   COMMENT 'Name of Membership Type'", [], TRUE, NULL, FALSE, FALSE);
+      }
+    }
+    else {
+      CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_membership_type CHANGE `name` `name` varchar(128) NOT NULL   COMMENT 'Name of Membership Type'", [], TRUE, NULL, FALSE, FALSE);
+    }
+    return TRUE;
+  }
+
 }