Update to 3.1.0 - failed to find conversion function from unknown to text

Including output in peertube.log here too:

[video.berocs.com:443] 2021-03-25 00:13:09.938 info: Begin migrations.
[video.berocs.com:443] 2021-03-25 00:13:09.944 info: Executing 0595-remote-url.js migration script.
[video.berocs.com:443] 2021-03-25 00:13:09.966 error: Cannot execute migration 0595. {
« err »: {
« stack »: « SequelizeDatabaseError: failed to find conversion function from unknown to text\n at Query.formatError (/var/www/peertube/versions/peertube-v3.1.0/node_modules/sequelize/lib/dialects/postgres/query.js:386:16)\n at Query.run (/var/www/peertube/versions/peertube-v3.1.0/node_modules/sequelize/lib/dialects/postgres/query.js:87:18)\n at processTicksAndRejections (internal/process/task_queues.js:93:5)\n at async /var/www/peertube/versions/peertube-v3.1.0/node_modules/sequelize/lib/sequelize.js:619:16 »,
« message »: « failed to find conversion function from unknown to text »,
« name »: « SequelizeDatabaseError »,
« parent »: {
« stack »: « error: failed to find conversion function from unknown to text\n at Parser.parseErrorMessage (/var/www/peertube/versions/peertube-v3.1.0/node_modules/pg-protocol/dist/parser.js:278:15)\n at Parser.handlePacket (/var/www/peertube/versions/peertube-v3.1.0/node_modules/pg-protocol/dist/parser.js:126:29)\n at Parser.parse (/var/www/peertube/versions/peertube-v3.1.0/node_modules/pg-protocol/dist/parser.js:39:38)\n at Socket. (/var/www/peertube/versions/peertube-v3.1.0/node_modules/pg-protocol/dist/index.js:10:42)\n at Socket.emit (events.js:315:20)\n at addChunk (internal/streams/readable.js:309:12)\n at readableAddChunk (internal/streams/readable.js:284:9)\n at Socket.Readable.push (internal/streams/readable.js:223:10)\n at TCP.onStreamRead (internal/stream_base_commons.js:188:23) »,
« message »: « failed to find conversion function from unknown to text »,
« length »: 117,
« name »: « error »,
« severity »: « ERROR »,
« code »: « XX000 »,
« file »: « parse_coerce.c »,
« line »: « 514 »,
« routine »: « coerce_type »,
« sql »: « UPDATE "videoFile" SET "torrentUrl" = t."serverUrl" || ‹ /static/torrents/ › || "videoFile"."torrentFilename", "fileUrl" = t."serverUrl" || t."filePath" || "videoFile"."filename" FROM (SELECT ‹ https:// › || server.host AS "serverUrl", ‹ /static/webseed/ › AS "filePath", "videoFile".id FROM video INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" INNER JOIN actor ON actor.id = "videoChannel"."actorId" INNER JOIN server ON server.id = actor."serverId" INNER JOIN "videoFile" ON "videoFile"."videoId" = video.id WHERE video.remote IS TRUE) AS t WHERE t.id = "videoFile"."id" AND "videoFile"."fileUrl" IS NULL »
},
« sql »: « UPDATE "videoFile" SET "torrentUrl" = t."serverUrl" || ‹ /static/torrents/ › || "videoFile"."torrentFilename", "fileUrl" = t."serverUrl" || t."filePath" || "videoFile"."filename" FROM (SELECT ‹ https:// › || server.host AS "serverUrl", ‹ /static/webseed/ › AS "filePath", "videoFile".id FROM video INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" INNER JOIN actor ON actor.id = "videoChannel"."actorId" INNER JOIN server ON server.id = actor."serverId" INNER JOIN "videoFile" ON "videoFile"."videoId" = video.id WHERE video.remote IS TRUE) AS t WHERE t.id = "videoFile"."id" AND "videoFile"."fileUrl" IS NULL »
}
}

Following from here: Database error during start peertube - #3 par shvonder

Restoring the database fails:

# pg_restore -U postgres -c -C -d postgres "sql-peertube_prod-21-03-24.sql"
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 3221; 1262 16385 DATABASE peertube_prod peertube
pg_restore: [archiver (db)] could not execute query: ERROR:  database "peertube_prod" does not exist
    Command was: DROP DATABASE peertube_prod;

WARNING: errors ignored on restore: 1