Nextcloud.oc_flow_operations_scope' doesn't exist - After Nextcloud upgrade 17->18

Nextcloud version: 17 -> 18
Operating system and version : 18.04
Apache or nginx version: 1.17.9
PHP version :PHP 7.3.16

The issue you are facing: Table ‘nextcloud.oc_flow_operations_scope’ doesn’t exist

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

Steps to replicate it:

  1. Upgrade NextCloud 16->17->18

logs:

$ sudo -u www-data php /var/www/nextcloud/occ upgrade -vvvv
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
2020-03-23T09:08:36+01:00 Set log level to debug
2020-03-23T09:08:36+01:00 Turned on maintenance mode
2020-03-23T09:08:36+01:00 Repair step: Repair MySQL collation
2020-03-23T09:08:36+01:00 Repair info: All tables already have the correct collation -> nothing to do
2020-03-23T09:08:36+01:00 Repair step: Repair SQLite autoincrement
2020-03-23T09:08:36+01:00 Repair step: Copy data from accounts table when migrating from ownCloud
2020-03-23T09:08:36+01:00 Repair step: Drop account terms table when migrating from ownCloud
2020-03-23T09:08:36+01:00 Updating database schema
2020-03-23T09:08:36+01:00 Updated database
2020-03-23T09:08:36+01:00 Updating …
2020-03-23T09:08:36+01:00 Repair step: Populating added database structures for workflows
2020-03-23T09:08:36+01:00 Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing ‘SELECT o.id FROM oc_flow_operations o LEFT JOIN oc_flow_operations_scope s ON o.id = s.operation_id WHERE s.operation_id IS NULL’:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘nextcloud.oc_flow_operations_scope’ doesn’t exist
2020-03-23T09:08:36+01:00 Update failed
2020-03-23T09:08:36+01:00 Maintenance mode is kept active
2020-03-23T09:08:36+01:00 Reset log level
labuser@pkml-server01:/usr/local/src$ sudo -u www-data php /var/www/nextcloud/occ maintenance:repair -vvvv
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade

  • Repair MySQL collation
    • All tables already have the correct collation -> nothing to do
  • Repair mime types
  • Clean tags and favorites
    • 0 tags of deleted users have been removed.
    • 0 tags for delete files have been removed.
    • 0 tag entries for deleted tags have been removed.
    • 0 tags with no entries have been removed.
  • Repair invalid shares
  • Move .step file of updater to backup location
  • Fix potential broken mount points
    • No mounts updated
  • Add log rotate job
  • Clear frontend caches
    • Image cache cleared
    • SCSS cache cleared
    • JS cache cleared
  • Clear every generated avatar on major updates
  • Add preview background cleanup job
  • Queue a one-time job to cleanup old backups of the updater
  • Cleanup invalid photocache files for carddav
  • Add background job to cleanup login flow v2 tokens
  • Remove potentially over exposing share links
    • No need to remove link shares.
  • Clear access cache of projects
  • Switches from deprecated “production” to “stable” update channel
  • Sets the enterprise logo
    • Repair step already executed
  • Reset generated avatar flag
  • Fix component of birthday calendars
    • 4 birthday calendars updated.
  • Regenerating birthday calendars to use new icons and fix old birthday events without year
    • Repair step already executed
  • Fix broken values of calendar objects
    0 [>---------------------------] < 1 sec 22.0 MiB
  • Registering building of calendar search index as background job
    • Repair step already executed
  • Registering background jobs to update cache for webcal calendars
    • Added 0 background jobs to update webcal calendars
  • Registering building of calendar reminder index as background job
    • Repair step already executed
  • Clean up orphan event and contact data
    • 0 events without a calendar have been cleaned up
    • 0 properties without an events have been cleaned up
    • 0 changes without a calendar have been cleaned up
    • 0 cached events without a calendar subscription have been cleaned up
    • 0 changes without a calendar subscription have been cleaned up
    • 0 contacts without an addressbook have been cleaned up
    • 0 properties without a contact have been cleaned up
    • 0 changes without an addressbook have been cleaned up
  • Remove activity entries of private events
    • Removed 0 activity entries
  • Fix the share type of guest shares when migrating from ownCloud
  • Copy the share password into the dedicated column
  • Set existing shares as accepted
  • Update OAuth token expiration times
  • Add background job to check for backup codes
  • Populating added database structures for workflows

In AbstractMySQLDriver.php line 42:

[Doctrine\DBAL\Exception\TableNotFoundException]
An exception occurred while executing ‘SELECT o.id FROM oc_flow_operations o LEFT JOIN oc_flow_operations_scope s ON o.id = s.operation_id WHERE s.operation _id IS NULL’:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘nextcloud.oc_flow_operations_scope’ doesn’t exist

Exception trace:
at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:42
Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException() at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:169
Doctrine\DBAL\DBALException::wrapException() at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:145
Doctrine\DBAL\DBALException::driverExceptionDuringQuery() at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:911
Doctrine\DBAL\Connection->executeQuery() at /var/www/nextcloud/lib/private/DB/Connection.php:199
OC\DB\Connection->executeQuery() at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php:200
Doctrine\DBAL\Query\QueryBuilder->execute() at /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php:215
OC\DB\QueryBuilder\QueryBuilder->execute() at /var/www/nextcloud/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php:86
OCA\WorkflowEngine\Migration\PopulateNewlyIntroducedDatabaseFields->getIdsWithoutScope() at /var/www/nextcloud/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php:48
OCA\WorkflowEngine\Migration\PopulateNewlyIntroducedDatabaseFields->run() at /var/www/nextcloud/lib/private/Repair.php:104
OC\Repair->run() at /var/www/nextcloud/core/Command/Maintenance/Repair.php:126
OC\Core\Command\Maintenance\Repair->execute() at /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:915
Symfony\Component\Console\Application->doRunCommand() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:272
Symfony\Component\Console\Application->doRun() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /var/www/nextcloud/lib/private/Console/Application.php:214
OC\Console\Application->run() at /var/www/nextcloud/console.php:99
require_once() at /var/www/nextcloud/occ:11

In PDOConnection.php line 90:

[Doctrine\DBAL\Driver\PDOException (42S02)]
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘nextcloud.oc_flow_operations_scope’ doesn’t exist

Exception trace:
at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:90
Doctrine\DBAL\Driver\PDOConnection->query() at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:908
Doctrine\DBAL\Connection->executeQuery() at /var/www/nextcloud/lib/private/DB/Connection.php:199
OC\DB\Connection->executeQuery() at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php:200
Doctrine\DBAL\Query\QueryBuilder->execute() at /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php:215
OC\DB\QueryBuilder\QueryBuilder->execute() at /var/www/nextcloud/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php:86
OCA\WorkflowEngine\Migration\PopulateNewlyIntroducedDatabaseFields->getIdsWithoutScope() at /var/www/nextcloud/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php:48
OCA\WorkflowEngine\Migration\PopulateNewlyIntroducedDatabaseFields->run() at /var/www/nextcloud/lib/private/Repair.php:104
OC\Repair->run() at /var/www/nextcloud/core/Command/Maintenance/Repair.php:126
OC\Core\Command\Maintenance\Repair->execute() at /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:915
Symfony\Component\Console\Application->doRunCommand() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:272
Symfony\Component\Console\Application->doRun() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /var/www/nextcloud/lib/private/Console/Application.php:214
OC\Console\Application->run() at /var/www/nextcloud/console.php:99
require_once() at /var/www/nextcloud/occ:11

In PDOConnection.php line 88:

[PDOException (42S02)]
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘nextcloud.oc_flow_operations_scope’ doesn’t exist

Exception trace:
at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:88
PDO->query() at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:88
Doctrine\DBAL\Driver\PDOConnection->query() at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:908
Doctrine\DBAL\Connection->executeQuery() at /var/www/nextcloud/lib/private/DB/Connection.php:199
OC\DB\Connection->executeQuery() at /var/www/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php:200
Doctrine\DBAL\Query\QueryBuilder->execute() at /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php:215
OC\DB\QueryBuilder\QueryBuilder->execute() at /var/www/nextcloud/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php:86
OCA\WorkflowEngine\Migration\PopulateNewlyIntroducedDatabaseFields->getIdsWithoutScope() at /var/www/nextcloud/apps/workflowengine/lib/Migration/PopulateNewlyIntroducedDatabaseFields.php:48
OCA\WorkflowEngine\Migration\PopulateNewlyIntroducedDatabaseFields->run() at /var/www/nextcloud/lib/private/Repair.php:104
OC\Repair->run() at /var/www/nextcloud/core/Command/Maintenance/Repair.php:126
OC\Core\Command\Maintenance\Repair->execute() at /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:915
Symfony\Component\Console\Application->doRunCommand() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:272
Symfony\Component\Console\Application->doRun() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /var/www/nextcloud/lib/private/Console/Application.php:214
OC\Console\Application->run() at /var/www/nextcloud/console.php:99
require_once() at /var/www/nextcloud/occ:11

maintenance:repair [–include-expensive]

sudo -u www-data php /var/www/nextcloud/occ migrations:status workflowengine -vvv
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade

In MigrationService.php line 453:

[InvalidArgumentException]
Migration step ‘OCA\WorkflowEngine\Migration\Version2000Date20190808074233’ is unknown

Exception trace:
at /var/www/nextcloud/lib/private/DB/MigrationService.php:453
OC\DB\MigrationService->createInstance() at /var/www/nextcloud/lib/private/DB/MigrationService.php:428
OC\DB\MigrationService->describeMigrationStep() at /var/www/nextcloud/core/Command/Db/Migrations/StatusCommand.php:107
OC\Core\Command\Db\Migrations\StatusCommand->getMigrationsInfos() at /var/www/nextcloud/core/Command/Db/Migrations/StatusCommand.php:60
OC\Core\Command\Db\Migrations\StatusCommand->execute() at /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:915
Symfony\Component\Console\Application->doRunCommand() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:272
Symfony\Component\Console\Application->doRun() at /var/www/nextcloud/3rdparty/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /var/www/nextcloud/lib/private/Console/Application.php:214
OC\Console\Application->run() at /var/www/nextcloud/console.php:99
require_once() at /var/www/nextcloud/occ:11

sudo -u www-data php /var/www/nextcloud/occ status

Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade

  • installed: true
  • version: 18.0.2.2
  • versionstring: 18.0.2
  • edition:

######## Solution ############

Found a solution that helped me to get 18.02 up and running. cheers /Pedro

cp apps/workflowengine/appinfo/database.xml ~/
rm -f apps/workflowengine/appinfo/database.xml
sudo -u www-data php /var/www/nextcloud/occ upgrade

4 Likes