Skip to content

Failed to convert DB from sqlite to MariaDB #5099

Description

@nerux1

Hi,

I will want migrate from SQLite to MariaDB, but I have a problem when I use the occ command.
It seems to have a problem with the primary key of the oc_preferences table.

Thanks,

Steps to reproduce

  1. php occ db:convert-type --clear-schema mysql nextclouduser 127.0.0.1 nextcloud
  2. wait...

Expected behaviour

Migrate from SQLite to MariaDB.

Actual behaviour

The script exit with error.

[...]
    0 [>---------------------------]oc_preferences
 28/59 [=============>--------------]  47%
                                                                                                                                                                                         
  [Doctrine\DBAL\Exception\UniqueConstraintViolationException]                                                                                                                           
  An exception occurred while executing 'INSERT INTO `oc_preferences` (`userid`, `appid`, `configkey`, `configvalue`) VALUES(?, ?, ?, ?)' with params ["XXXX", "calendar", "currentView", "month"]:                                                                                                                                                                        
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'XXXX-calendar-currentView' for key 'PRIMARY'                                                                                             
  [Doctrine\DBAL\Driver\PDOException]                                                                                     
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'XXXX-calendar-currentView' for key 'PRIMARY'                                                                                             
  [PDOException]                                                                                                          
  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'XXXX-calendar-currentView' for key 'PRIMARY' 

Server configuration

Operating system: arch

Web server: nginx 1.12.0

Database: mariadb 10.1.23

PHP version: 7.1.5

Nextcloud version: 12.0.0.19

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from: package arch

Activity

  1. koppd commented on Jun 20, 2017

    @koppd

    I had the same issue. I guess your sqlite database has these 2 entries in the table oc_preferences:

    • XXXX-calendar-currentView
    • XXXX-calendar-currentview

    I looks like that sqlite tables ARE case-sensitive and mysql table are NOT. That's why you get an error (duplicate entry for PRIMARY KEY).

    I solved that issue by removing one of the two lines (I guess it was "currentview") in the sqlite database (=data/owncloud.db).
    For the removal I used the "SQLite Manager" which is a Firefox Extension.
    But I'm sure there's a 2-3 liner at the terminal level, which is doing the same, but more elegant.

  2. nerux1 commented on Jun 21, 2017

    @nerux1
    Author

    Yes, it works ;)
    I had must suppress currentView and currentview
    sqlite> delete from oc_preferences where (configkey = 'currentView' or configkey = 'currentview') and appid = 'calendar';

    Thanks for your help.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions