Проблема миграции БД с MySQL в PostgreSQL

Started by tusov, April 12, 2018, 10:35:54 AM

Previous topic - Next topic

tusov

Добрый день,
Столкнулся с проблемой не выполняется миграция данных с базы MySQL в PostgreSQL выдает ошибку (полный лог во вложении):

Migrating table nodes
SQL query failed (22P02 ОШИБКА:  неверное значение для целого числа: ""):
INSERT INTO nodes (id,primary_name,primary_ip,node_flags,runtime_flags,snmp_version,snmp_port,community,usm_auth_password,usm_priv_password,usm_methods,snmp_oid,auth_method,secret,agent_port,status_poll_type,agent_version,platform_name,poller_node_id,zone_guid,proxy_node,snmp_proxy,icmp_proxy,required_polls,uname,use_ifxtable,snmp_sys_name,snmp_sys_contact,snmp_sys_location,bridge_base_addr,down_since,boot_time,driver_name,rack_image_front,rack_position,rack_height,rack_id,agent_cache_mode,last_agent_comm_time,syslog_msg_count,snmp_trap_count,chassis_id,node_type,node_subtype,ssh_login,ssh_password,ssh_proxy,port_rows,port_numbering_scheme,agent_comp_mode,tunnel_id,lldp_id,fail_time_snmp,fail_time_agent,rack_orientation,rack_image_rear) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)

...

Database migration failed.


Версии программ:

NetXMS Database Manager Version 2.2.4 Build 9506 (2.2.4)

mysql  Ver 14.14 Distrib 5.5.53, for debian-linux-gnu (x86_64) using readline 6.3

psql (PostgreSQL) 10.3 (Debian 10.3-1.pgdg80+1)


Миграцию выполняю по инструкции https://wiki.netxms.org/wiki/How_to_migrate_to_another_database

Кто что посоветует?


tusov

Разобрался в причине ошибки

Некоторые узлы в таблице nodes в полях port_rows, port_numbering_scheme имеют значение NULL, но как я в момент миграции для этих полей значения заменяются на "" на что и ругается затем PostgreSQL так как "" - это строка, а указанные поля типа число

в моем случае помогло проставить в MySQL  вместо null значение например -1:

update netxms.nodes
set port_numbering_scheme = -1
where
port_numbering_scheme is null;

update netxms.nodes
set port_rows = -1
where
port_rows is null;


Выполнил
nxdbmgr migrate /etc/netxmsd.conf.old

а затем в PostgreSQL вернул null обратно:
update nodes
set port_numbering_scheme = null
where
port_numbering_scheme = -1;

update nodes
set port_rows = null
where
port_rows = -1;


Просьба к разработчика: исправьте данный баг