nextcloud 切换数据库 mysql->PostgreSQL(sqlite->mysql同理) 遇到的一些问题 Docker版

in 笔记 with 0 comment

nextcloud 切换数据库 mysql->PostgreSQL(sqlite->mysql同理) 遇到的一些问题 Docker版


在V2ex看到有老哥说nextcloud和PostgreSQL更搭配,所以萌生了切换数据库的想法。

官方文档说明
https://docs.nextcloud.com/server/19/admin_manual/configuration_database/db_conversion.html

官方给出的命令

php occ db:convert-type [options] type username hostname database

但文档中并没说明其中type的枚举值,在实行的过程中是直接用PostgreSQL

便会显示无此类型
只能在代码里排查一下问题所在

\lib\private\DB\ConnectionFactory.php

报错代码如下

    /**
     * @var array
     *
     * Array mapping DBMS type to default connection parameters passed to
     * \Doctrine\DBAL\DriverManager::getConnection().
     */
    protected $defaultConnectionParams = [
        'mysql' => [
            'adapter' => AdapterMySQL::class,
            'charset' => 'UTF8',
            'driver' => 'pdo_mysql',
            'wrapperClass' => Connection::class,
        ],
        'oci' => [
            'adapter' => AdapterOCI8::class,
            'charset' => 'AL32UTF8',
            'driver' => 'oci8',
            'wrapperClass' => OracleConnection::class,
        ],
        'pgsql' => [
            'adapter' => AdapterPgSql::class,
            'driver' => 'pdo_pgsql',
            'wrapperClass' => Connection::class,
        ],
        'sqlite3' => [
            'adapter' => AdapterSqlite::class,
            'driver' => 'pdo_sqlite',
            'wrapperClass' => Connection::class,
        ],
    ];

所以type对于的码值应该是 mysql,oci,pgsql,sqlite3

所以最终的命令应该是

docker exec --user www-data nextcloud php occ db:convert-type --port="5432" --password="password" --clear-schema --all-apps pgsql username  hostname database

只需等待数分钟之后,就:ok_hand:了

Responses