Skip to content

Upgrade fails with - Column name "oc_flow_operations.entity" is "NotNull", but has empty string or null as default #23174

Closed

Description

@dbtech

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Steps to reproduce

  1. start occ upgrade

Expected behaviour

occ upgrade should be completed.

Actual behaviour

InvalidArgumentException: Column name oc_flow_operations.entity is NotNull, but has empty string or null as default.

Server configuration

Operating system:
Ubuntu Linux 20.04

Web server:
N/A (not used)

Database:
postgresql 11

PHP version:
7.4

Nextcloud version: (see Nextcloud admin page)
20.0.0

Updated from an older Nextcloud/ownCloud or fresh install:
Fresh install with manual DB upgrade 17.0.3.1

Where did you install Nextcloud from:
https://download.nextcloud.com/server/releases/nextcloud-20.0.0.zip

Signing status:

Signing status Results ======= - core - INVALID_HASH - lib/private/DB/MigrationService.php REMARK ======= In order to proceed with the migration I had to PATCH the script above. It simply reverts the commit #5023084 (Sept. 7, 2020). I cannot reproduce the original list any more: It must have been empty though.

List of activated apps:

App list - accessibility: 1.6.0 - activity: 2.13.1 - cloud_federation_api: 1.3.0 - comments: 1.10.0 - contactsinteraction: 1.1.0 - dashboard: 7.0.0 - dav: 1.16.0 - federatedfilesharing: 1.10.1 - federation: 1.10.1 - files: 1.15.0 - files_pdfviewer: 2.0.1 - files_rightclick: 0.17.0 - files_sharing: 1.12.0 - files_trashbin: 1.10.1 - files_versions: 1.13.0 - files_videoplayer: 1.9.0 - firstrunwizard: 2.9.0 - logreader: 2.5.0 - lookup_server_connector: 1.8.0 - nextcloud_announcements: 1.9.0 - notifications: 2.8.0 - oauth2: 1.8.0 - password_policy: 1.10.1 - photos: 1.2.0 - privacy: 1.4.0 - provisioning_api: 1.10.0 - recommendations: 0.8.0 - serverinfo: 1.10.0 - settings: 1.2.0 - sharebymail: 1.10.0 - support: 1.3.0 - survey_client: 1.8.0 - systemtags: 1.10.0 - text: 3.1.0 - theming: 1.11.0 - twofactor_backupcodes: 1.9.0 - updatenotification: 1.10.0 - user_status: 1.0.0 - viewer: 1.4.0 - weather_status: 1.0.0 - workflowengine: 2.2.0

Nextcloud configuration:

Config report { "system": { "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "***REMOVED SENSITIVE VALUE***" ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "dbtype": "pgsql", "version": "20.0.0.9", "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbport": "", "dbtableprefix": "oc_", "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "updater.secret": "***REMOVED SENSITIVE VALUE***", "maintenance": false, "theme": "", "loglevel": 2 } }

Are you using external storage, if yes which one: local/smb/sftp/...
no

Are you using encryption: yes/no
no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
no

Client configuration

Browser:
N/A

Operating system:
N/A

Logs

Web server error log

Web server error log N/A (not used)

Nextcloud log (data/nextcloud.log)

Nextcloud log {"reqId":"rLfAg75MvoDInc4Ag522","level":3,"time":"2020-10-04T11:01:02+00:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":{"Exception":"InvalidArgumentException","Message":"Column name \"oc_flow_operations\".\"entity\" is NotNull, but has empty string or null as default.","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":484,"function":"ensureOracleIdentifierLengthLimit","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/MigrationService.php","line":414,"function":"executeStep","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":976,"function":"migrate","class":"OC\\DB\\MigrationService","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":375,"function":"updateApp","class":"OC_App","type":"::","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":254,"function":"doAppUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/lib/private/Updater.php","line":130,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/core/Command/Upgrade.php","line":255,"function":"upgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Command/Command.php","line":255,"function":"execute","class":"OC\\Core\\Command\\Upgrade","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":1000,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":271,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/console/Application.php","line":147,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/lib/private/Console/Application.php","line":215,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/console.php","line":100,"function":"run","class":"OC\\Console\\Application","type":"->"},{"file":"/var/www/nextcloud/occ","line":11,"args":["/var/www/nextcloud/console.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/DB/MigrationService.php","Line":519,"CustomMessage":"--"},"userAgent":"--","version":"20.0.0"}

Browser log

Browser log N/A (not used)

Activity

  1. added
    0. Needs triage
    on Oct 4, 2020
  2. darian-heede commented on Oct 7, 2020

    @darian-heede

    I solved this issue. First off, my setup is probably different than @dbtech as I'm running nextcloud and the postgres database in docker containers. As the described issue lies within a table in the postgres database, the fix should work for every kind of setup though.

    The error message implies that there is an issue with the default of column entity in table oc_flow_operations. It turns out the column entity was missing from the table entirely. Hence, I just added the column to the table. The following steps solved the issue:

    1. Log into the database container running psql:
      sudo docker exec -it <nextcloud-database> psql -U <database-user>
      This step is obviously specific to my type of setup but should be easily adapted for any other.
    2. Connect to the nextcloud database (should be default):
      \c <database-name>
    3. Check if the column is available:
      SELECT entity FROM oc_flow_operations;
      If this command returns
      ERROR: column "entity" does not exist
    4. Add the column to the table
    ALTER TABLE oc_flow_operations
    ADD COLUMN entity VARCHAR NOT NULL;
    1. Run the Update on the nextcloud webpage.

    I hope this helps.

  3. dbtech commented on Oct 7, 2020

    @dbtech
    Author

    Sorry @darian-heede, you misunderstand the issue. The error occurs after the "entity" column has been added with a default value of the empty string, i.e >''<. This is part of the database migration. The lib/private/DB/MigrationService.php script will verify if the default value is not null and not empty. This cannot succeed and an exception is raised. The column definition and the verification logic contradict each other and at least one of them should be corrected.

  4. kbuc commented on Oct 8, 2020

    @kbuc

    I just got this error while upgrading from 17.0.10 to 18.0.10. Also with me, the column entity did not exist (but the error message was the same). Added it with:

    alter table oc_flow_operations add column entity character varying(256) not null;

    then occ update finished the job.

  5. dbtech commented on Oct 8, 2020

    @dbtech
    Author

    Please be aware that the reported error is unrelated to any versions below 20.0.0. The error may occur only after Sep 7, 2020, due to the commit 5023084. For this reason I have strong doubts that @kbuc could have experienced the very same error in the versions 17 and 18.

  6. kbuc commented on Oct 8, 2020

    @kbuc

    @dbtech Yes, I experienced it today when updating from 17.0.9. It first updated to 17.0.10, then it wanted to update to 18.0.10 and this happened.
    As it seems, 17.0.10 release has today's date, so it might contain the mentioned commit?

  7. Cybso commented on Oct 8, 2020

    @Cybso

    Confirmed for upgrading from 17.0.10 to 18.0.10. Adding the column manually resolved the issue.

  8. dbtech commented on Oct 8, 2020

    @dbtech
    Author

    FYI: today's version of 17.0.10 does NOT contain the offending commit. Actually it would be weird if it did. I assume that the release was extracted today with the correct tag. Of course, I do not doubt that there might be similar errors in earlier releases. The reported error is brand new.

  9. Cybso commented on Oct 8, 2020

    @Cybso

    @dbtech I did the updates a few hours ago. First from 17.0.2 to 17.0.10, which went fine, and then to 18.0.10, which produced that error.

  10. dbtech commented on Oct 8, 2020

    @dbtech
    Author

    OK, I see a long series of comments above. Two of them refer "this" or "that" error during a migration to release 17.0.10. What was the error message exactly?

  11. Cybso commented on Oct 8, 2020

    @Cybso

    I've closed the console window already, but I've googled for:

    "InvalidArgumentException: Column name "oc_flow_operations"."entity" is NotNull, but has empty string or null as default"

    EDIT: Oh, and it was a migration FROM 17.0.10 to 18.0.10. The migration TO 17.0.10 was fine.

  12. mtapoja commented on Oct 8, 2020

    @mtapoja

    Confirmed for upgrading from 17.0.10 to 18.0.10. Adding the column manually resolved the issue.

    Same here, adding the column seems to fix the issue and next manual upgrade succeeded.

  13. 38 remaining items

  14. grisu48 commented on Nov 14, 2020

    @grisu48

    Also affected by this bug but could fix it by adding the missing column manually as suggested:

     ALTER TABLE oc_flow_operations ADD COLUMN `entity` varchar(256) NOT NULL;
    
  15. CaptPicardFR commented on Nov 16, 2020

    @CaptPicardFR

    ALTER TABLE oc_flow_operations ADD COLUMN entity VARCHAR; > error

    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1

    alter table oc_flow_operations add column entity character varying(256) not null; > OK !!!! MANY THANKS UPGRADE ok

  16. Kinamo commented on Nov 16, 2020

    @Kinamo

    Also affected by this bug but could fix it by adding the missing column manually as suggested:

     ALTER TABLE oc_flow_operations ADD COLUMN `entity` varchar(256) NOT NULL;
    

    Works perfectly for MySQL / MariaDB!

  17. ChadGnad commented on Nov 22, 2020

    @ChadGnad

    I hit the same error as others mentioned during 17.0.10.1 -> 18.0.10.2

    "File":"/config/www/nextcloud/lib/private/DB/MigrationService.php","Line":519
    Updater::failure: InvalidArgumentException: Column name "oc_flow_operations"."entity" is NotNull, but has empty string or null as default."

    when adding a column the validation method does not consider the case of an empty table. which should allow a null default & NonNull scenario
    if ($thing->getNotnull() && $thing->getDefault() === '' && $sourceTable instanceof Table && !$sourceTable->hasColumn($thing->getName())) {
    throw new \InvalidArgumentException('Column name "' . $table->getName() . '"."' . $thing->getName() . '" is NotNull, but has empty string or null as default.');
    }

    So I modified /config/www/nextcloud/apps/workflowengine/lib/Migration/Version2000Date20190808074233.php
    to set the default value of the entity column to space ' ' instead of blank ''; in lieu modifying MigrationService
    image

    Then re-ran with occ upgrade and success.

    I figured its better than allowing nulls into that column, but the integrity check on that file flags in the GUI post-migration.
    image

    This...this worked for me...it looks like someone removed the " and added ' ' but there was no space between. so I found <space ''> and did <space 'space'>

  18. Gaertjen commented on Dec 7, 2020

    @Gaertjen

    I'm sorry, I'm new here and do not understand very well, how you fixed it. I can't enter any commands? I just got the web interface to update the nextcloudsoftware, when I update to 18.0.11 it shows

    InvalidArgumentException: Column name "nc_5047_flow_operations"."entity" is NotNull, but has empty string or null as default.

    But I don't understand how to fix it. I'm really sorry, can anybody help me?

  19. blizzz commented on Dec 7, 2020

    @blizzz
    Member

    apply the changes from https://github.com/nextcloud/server/pull/24315/files and rerun the upgrade

  20. Gaertjen commented on Dec 13, 2020

    @Gaertjen

    apply the changes from https://github.com/nextcloud/server/pull/24315/files and rerun the upgrade

    thank you very much, I tried this but now it shows the following report. I am a bit confused

    prepare Update
    Log-Level Set to "debug"
    Maintenance mode switched on
    Repair steo: Repair MySQL collation
    Repair information: All tables already have the correct collation -> nothing to do
    Repair step: Repair SQLite autoincrement
    Repair step: Copy data from accounts table when migrating from ownCloud
    Repair step: Drop account terms table when migrating from ownCloud
    The database schema is updated
    Database updated
    An error has occurred.

  21. blizzz commented on Dec 15, 2020

    @blizzz
    Member

    An error has occurred.

    check the nextcloud.log

  22. Gaertjen commented on Dec 16, 2020

    @Gaertjen

    An error has occurred.

    check the nextcloud.log

    can you tell me what to check? if it's there?

  23. blizzz commented on Dec 16, 2020

    @blizzz
    Member

    An error has occurred.

    check the nextcloud.log

    can you tell me what to check? if it's there?

    An exception most likely.

  24. Gaertjen commented on Dec 17, 2020

    @Gaertjen

    An error has occurred.

    check the nextcloud.log

    can you tell me what to check? if it's there?

    An exception most likely.

    I found it, but it's empty. there is also a "updater.log". can this file help? and thank you for your great patience <3

  25. Gaertjen commented on Dec 29, 2020

    @Gaertjen

    An error has occurred.

    check the nextcloud.log

    can you tell me what to check? if it's there?

    An exception most likely.

    @blizzz do you have any ideas? or do you know how I can save the data in this situation?

  26. blizzz commented on Jan 4, 2021

    @blizzz
    Member

    it should not be empty. do you have the correct one? it should be in your data directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    1. to developbugfeature: install and update

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions