Update Error: twofactor_backupcodes

Nextcloud version (eg, 20.0.5): 12.0.12
Operating system and version (eg, Ubuntu 20.04): Ubuntu 18.04.2 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.29 (Ubuntu)
PHP version (eg, 7.4): PHP 7.1.29

The issue you are facing:
Hello there!

I have decided to move from owncloud do nexcloud. Migration went rather flawless but, now, during the first update from 12 → 13, I have encountered an error during the update of twofactor_backupcodes. Updater wants to update mysql with null command: “Column ‘used’ cannot be null”.

Anyone got similar problem? I have tried to disable/remove twofactor_backupcodes, but it’s impossible.

Updating <twofactor_backupcodes> ...
Doctrine\DBAL\Exception\NotNullConstraintViolationException: An exception occurred while executing 'INSERT INTO `oc_twofactor_backupcodes` (`user_id`, `code`, `used`) VALUES(?, ?, ?)' with params ["***", "***", null]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'used' cannot be null
Update failed

Unfortunately I have run out of ideas how to fix this.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Update from owncloud 10.0 to Nexcloud 12, then to 13

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'trusted_domains' => 
  array (
    
  ),
  'dbtype' => 'mysql',
  'version' => '12.0.12.2',
  'dbhost' => 'localhost',
  'dbtableprefix' => 'oc_',
  'logtimezone' => 'UTC',
  'installed' => true,
  'log_type' => 'owncloud',
  'logfile' => 'owncloud.log',
  'loglevel' => '3',
  'logdateformat' => 'F d, Y H:i:s',
  'maintenance' => false,
  'theme' => '',
  'enable_previews' => true,
);

Gave up and upgraded Owncloud manually (web-updater broke during process) to latest version (10.11) and then manually to latest (25) nextcloud. During the process had a few problems, mainly with connection to mysql database - all the problems were connected with a lack of php modules (mainly mysql and xml) or incorrect version of php. Finally I’m running v25.