Answers.Body: <p>Issue caused by empty timestamps in 'civicrm_note' according to <strong><a href="https://stackoverflow.com/questions/22971586/mysql-alter-table-causes-error-invalid-use-of-null-value/22971654">this</a></strong><br />
  The fix: run MySQL query before upgrade or if/when upgrade stuck.
  In my case, this page <a href="http://example.org/civicrm/upgrade?reset=1" rel="nofollow noreferrer">http://example.org/civicrm/upgrade?reset=1</a>  throws the MySQl error but after running the query below and refreshing the <a href="http://example.org/civicrm/upgrade?reset=1" rel="nofollow noreferrer">http://example.org/civicrm/upgrade?reset=1</a> it all went well.</p>
  <pre><code>UPDATE  `civicrm_note`
  SET `note_date`  = CURRENT_TIMESTAMP
  WHERE `note_date`  IS NULL;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-11T11:07:23.617Z
Answers.LastActivityDate: 2021-11-11T21:18:09.817Z
Answers.LastEditDate: 2021-11-11T21:18:09.817Z
Answers.UserDisplayName: yurg
Body: <p>Not much ( not at all ) regarding this found via <a href="https://lab.civicrm.org/groups/dev/-/issues" rel="nofollow noreferrer">https://lab.civicrm.org/groups/dev/-/issues</a>.</p>
  <pre><code>[code] =&gt; -1
  [message] =&gt; DB Error: unknown error
  [mode] =&gt; 16
  [debug_info] =&gt; ALTER TABLE civicrm_note CHANGE COLUMN
  `note_date` `note_date` timestamp NOT NULL DEFAULT
  current_timestamp() COMMENT 'Date attached to the note'
  [nativecode=1138 ** Invalid use of NULL value]
  [type] =&gt; DB_Error
  [user_info] =&gt; ALTER TABLE civicrm_note CHANGE COLUMN `note_date`
  `note_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT
  'Date attached to the note' [nativecode=1138 ** Invalid use of NULL
  value]
  [to_string] =&gt; [db_error: message=&quot;DB Error: unknown error&quot;
  code=-1 mode=callback callback=CRM_Core_Error::exceptionHandler
  prefix=&quot;&quot; info=&quot;ALTER TABLE civicrm_note CHANGE COLUMN `note_date`
  `note_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT
   Date attached to the note' [nativecode=1138 ** Invalid use of NULL
   value]&quot;]
   )
  
  PEAR_Exception: &quot;DB Error: unknown error&quot;
  * ERROR TYPE: DB_Error
  * ERROR CODE: -1
  * ERROR MESSAGE: DB Error: unknown error
  * ERROR MODE: 16
  * ERROR USERINFO: ALTER TABLE civicrm_note CHANGE COLUMN `note_date` `note_date` 
  timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date attached to the note' 
  [nativecode=1138 ** Invalid use of NULL value]
  * ERROR DEBUGINFO: ALTER TABLE civicrm_note CHANGE COLUMN `note_date` `note_date` 
  timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date attached to the note' 
  [nativecode=1138 ** Invalid use of NULL value]
  #0 /var/www/drupal/sites/all/modules/civicrm/vendor/pear/pear-core- 
  minimal/src/PEAR.php(922): CRM_Core_Error::exceptionHandler(Object(DB_Error))
  #1 /var/www/drupal/sites/all/modules/civicrm/vendor/pear/db/DB.php(998): PEAR_Error- 
  &gt;__construct(&quot;DB Error: unknown error&quot;, -1, 16, (Array:2), &quot;ALTER TABLE civicrm_note 
  CHANGE COLUMN `note_date` `note_date` timestamp NOT ...&quot;)
  </code></pre>
  
Tags: <upgrade>
Title: CiviCRM 5.37 > CiviCRM 5.43 upgrade, drush cvupdb, ALTER TABLE civicrm_note CHANGE COLUMN note_date Invalid use of NULL value
ThreadText: # CiviCRM 5.37 > CiviCRM 5.43 upgrade, drush cvupdb, ALTER TABLE civicrm_note CHANGE COLUMN note_date Invalid use of NULL value
  
  (Asked by: username_0 on 2021-11-11)
  
  Not much ( not at all ) regarding this found via https://lab.civicrm.org/groups/dev/-/issues.
  [code] => -1
  [message] => DB Error: unknown error
  [mode] => 16
  [debug_info] => ALTER TABLE civicrm_note CHANGE COLUMN
  `note_date` `note_date` timestamp NOT NULL DEFAULT
  current_timestamp() COMMENT 'Date attached to the note'
  [nativecode=1138 ** Invalid use of NULL value]
  [type] => DB_Error
  [user_info] => ALTER TABLE civicrm_note CHANGE COLUMN `note_date`
  `note_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT
  'Date attached to the note' [nativecode=1138 ** Invalid use of NULL
  value]
  [to_string] => [db_error: message="DB Error: unknown error"
  code=-1 mode=callback callback=CRM_Core_Error::exceptionHandler
  prefix="" info="ALTER TABLE civicrm_note CHANGE COLUMN `note_date`
  `note_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT
   Date attached to the note' [nativecode=1138 ** Invalid use of NULL
   value]"]
   )
  
  PEAR_Exception: "DB Error: unknown error"
  * ERROR TYPE: DB_Error
  * ERROR CODE: -1
  * ERROR MESSAGE: DB Error: unknown error
  * ERROR MODE: 16
  * ERROR USERINFO: ALTER TABLE civicrm_note CHANGE COLUMN `note_date` `note_date` 
  timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date attached to the note' 
  [nativecode=1138 ** Invalid use of NULL value]
  * ERROR DEBUGINFO: ALTER TABLE civicrm_note CHANGE COLUMN `note_date` `note_date` 
  timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date attached to the note' 
  [nativecode=1138 ** Invalid use of NULL value]
  #0 /var/www/drupal/sites/all/modules/civicrm/vendor/pear/pear-core- 
  minimal/src/PEAR.php(922): CRM_Core_Error::exceptionHandler(Object(DB_Error))
  #1 /var/www/drupal/sites/all/modules/civicrm/vendor/pear/db/DB.php(998): PEAR_Error- 
  >__construct("DB Error: unknown error", -1, 16, (Array:2), "ALTER TABLE civicrm_note 
  CHANGE COLUMN `note_date` `note_date` timestamp NOT ...")
  
  **Tags:** upgrade
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-11-11. Score: 2
  
  Issue caused by empty timestamps in 'civicrm_note' according to this
  The fix: run MySQL query before upgrade or if/when upgrade stuck.
  In my case, this page http://example.org/civicrm/upgrade?reset=1  throws the MySQl error but after running the query below and refreshing the http://example.org/civicrm/upgrade?reset=1 it all went well.
  UPDATE  `civicrm_note`
  SET `note_date`  = CURRENT_TIMESTAMP
  WHERE `note_date`  IS NULL;
  
  
  ---
  
  