Skip to content

OC7: Problems converting from SQLite3 to PostgresQL #9891

Description

@jmaerki

(Move here from http://forum.owncloud.org/viewtopic.php?f=29&t=22446)

I've just upgraded to OwnCloud 7 and the upgrade went well. It's currently running on SQLite and I would like to migrate to PostgresQL since I've run into concurrency problems due to the usage of multiple devices.

Steps to reproduce

So, after finding #9526 I adjusted the call to the following:
sudo php occ db:convert-type --password="wonttell" --all-apps pgsql owncloud localhost owncloud

Expected behaviour

Well, just a regular migration from SQLite to PostgresQL.

Actual behaviour

The first issue was:

    oc_filecache
      8810/20428 [============>---------------]  43%

     [Doctrine\DBAL\DBALException]
      An exception occurred while executing 'INSERT INTO oc_filecache ("fileid", "storage", "parent", "name", "mimetype", "mimepart", "mtime", "encrypted", "path
      _hash", "etag", "storage_mtime", "path", "size", "unencrypted_size", "permissions") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["209
      08", "7", "20905", "\x31\x35 [..] \x6d\x70\x33", "11", "10", "1295508789", "0", "[..]", "[..]", "1295508789", "\x4d
      \x75\x73\x69\ [..] \xb4\x74 [..]", "3903543", "0", "0"]:

      SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0xb4

      [PDOException]
      SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0xb4

I've replaced some content with [..] above to obfuscate the actual data. Anyway, the Postgres database is set up as described in the manual. It says "UTF-8" as encoding, but I suspect this is coming from the reading side somehow.

I read somewhere that it is possible to reset the file cache, so I ran "sqlite3 owncloud.db" and "DELETE FROM oc_filecache;" and that actually brought me past this first issue.

But then I ran into the following:

    oc_contacts_cards_properties
      365/1516 [======>---------------------]  24%

      [Doctrine\DBAL\DBALException]
      An exception occurred while executing 'INSERT INTO oc_contacts_cards_properties ("id", "name", "value", "preferred", "userid", "contactid") VALUES (?, ?, ?, ?, ?, ?)' with params ["486", "PHOTO", "\/9j\/4AAQS [..] 8A\/9k=", "0", "[..]", "73"]:

      SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(255)

      [PDOException]
      SQLSTATE[22001]: String data, right truncated: 7 ERROR:  value too long for type character varying(255)

"value" is quite big, surely more than 255 characters. Given that the parameter is called "PHOTO" I assume a base64-encoded JPEG image associated with a contact. But on the PostgresQL table created the column "value" is just "value character varying(255) DEFAULT NULL::character varying" which explains the problem. Should this maybe be a "text" or blob?

Server configuration

Operating system: Linux 3.10.25+ armv6l (RaspberryPi)

Web server: Apache HTTPD 2.2.22

Database: SQLite3 3.7.13, PostgresQL 9.1.13

PHP version: 5.4.4-14+deb7u12

ownCloud version: 7.0.0

Updated from an older ownCloud or fresh install: Updated from latest OC 6.x

List of activated apps: Standard apps + Mozilla Sync

The content of config/config.php:

<?php
$CONFIG = array (
  'instanceid' => '51bc88cb8abfa',
  'passwordsalt' => '*** Removed for security reasons',
  'datadirectory' => '/var/www/owncloud/data',
  'dbtype' => 'sqlite3',
  'version' => '7.0.0.8',
  'installed' => true,
  'loglevel' => '1',
  'forcessl' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpdebug' => true,
  'mail_smtphost' => 'mail.wonttell',
  'mail_smtpauth' => true,
  'mail_smtpsecure' => 'tls',
  'mail_smtpname' => 'wonttell',
  'mail_smtppassword' => '*** Removed for security reasons',
  'theme' => '',
  'maintenance' => false,
  'appstoreenabled' => true,
  'appstoreurl' => 'http://api.apps.owncloud.com/v1',
  'trusted_domains' =>
  array (
    0 => 'wonttell.domain',
  ),
);

Are you using external storage, if yes which one: local (external USB drive)

Are you using encryption: yes

Client configuration

n/a here

Logs

Web server error log

n/a here

ownCloud log (data/owncloud.log)

I've got quite a few of these in the logs even before the upgrade to OC7 which could be relevant:

{"app":"core","message":null,"level":2,"time":"2014-07-24T08:29:30+00:00"}
{"app":"PHP","message":"json_encode(): Invalid UTF-8 sequence in argument at \/mnt\/usbdrive\/www\/owncloud\/lib\/private\/log\/owncloud.php#86","level":3,"time":"2014-07-24T08:29:30+00:00"}

Otherwise, I don't see anything in the logs that could be applicable to this problem.

Browser log

n/a here

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions