我很难让 pgloader 在一个特定数据库上将 mysql 转换为 postgres。
运行 pgloader 时收到以下错误消息
[root@38AA08C pgsql]# pgloader pg_load
2023-06-21T03:13:59.006000+01:00 LOG pgloader version "3.6.7~devel"
2023-06-21T03:13:59.893030+01:00 LOG Migrating from #<MYSQL-CONNECTION mysql://******* {10068EB193}>
2023-06-21T03:13:59.893030+01:00 LOG Migrating into #<PGSQL-CONNECTION pgsql://******* {10068EB333}>
KABOOM!
UNDEFINED-COLUMN: Database error 42703: column ""output_ID"" of relation "hir_2016_model_assessment" does not exist
CONTEXT: PL/pgSQL function inline_code_block line 6 at FOR over SELECT rows
QUERY:
DO $$
DECLARE
n integer := 0;
r record;
BEGIN
FOR r in
SELECT 'select '
|| trim(trailing ')'
如您所见,该列确实存在
Table "public.hir_2016_model_assessment"
Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description
------------------------+----------------+-----------+----------+----------------------------------------------------------------+---------+-------------+--------------+-------------
output_ID | bigint | | not null | nextval('"hir_2016_model_assessment_output_ID_seq"'::regclass) | plain | | |
project_ID | integer | | not null | | plain | | |
我的加载文件看起来像这样
LOAD DATABASE
FROM mysql://*****
INTO postgresql://*****
alter schema 'regen' rename to 'public'
WITH
include drop, create tables, create indexes, reset sequences, schema only, quote identifiers,
multiple readers per thread, rows per range = 50000
SET PostgreSQL PARAMETERS
maintenance_work_mem to '1GB'
SET MySQL PARAMETERS
net_read_timeout = '31536000',
net_write_timeout = '31536000',
lock_wait_timeout = '31536000'
CAST
type enum to text drop not null using empty-string-to-null,
type date drop not null drop default using zero-dates-to-null,
type datetime to timestamp drop default using zero-dates-to-null,
type bigint when unsigned to numeric drop typemod,
type bigint when (<= precision 20) to bigint drop typemod,
type geography to bytea,
type geometry to point using convert-mysql-point,
type point to point using convert-mysql-point
-- BEFORE LOAD DO
-- $$ create extension if not exists postgis; $$
;
我一整天都在为此苦苦挣扎。有什么线索可能导致此失败吗?
这是 pgloader 中的一个已知问题,当针对区分大小写的列运行
reset sequences
选项时会发生该问题。但它尚未合并:https://github.com/dimitri/pgloader/pull/1509