Upgrade database from 2.21 to 2.22 error

Started by Luiz A. Camilo, September 04, 2008, 11:38:53 PM

Previous topic - Next topic

Luiz A. Camilo

I was trying to upgrade to the newest version, and when upgrading the database, I get an error ...

C:\NetXMS\bin>nxdbmgr upgrade -t
NetXMS Database Manager Version 0.2.22

Configuration file OK
Upgrading database...
Upgrading from version 80 to 81
>>> SELECT item_id,schedule FROM dci_schedules
>>> DELETE FROM dci_schedules
>>> ALTER TABLE dci_schedules ADD schedule_id integer not null
SQL query failed (General SQL Server error: Check messages from the SQL Server.)
:
ALTER TABLE dci_schedules ADD schedule_id integer not null
Rolling back last stage due to upgrade errors...
Database upgrade failed

When trying to execute the same command from Query analyzer, I get this error back :

ALTER TABLE only allows columns to be added that can contain nulls or have a DEFAULT definition specified. Column 'schedule_id' cannot be added to table 'dci_schedules' because it does not allow nulls and does not specify a DEFAULT definition.

I need ideas ...

Victor Kirhenshtein

Looks like a bug in handling MS SQL on upgrade (it works fine on my test system, but I have MS SQL 2005). Try to do an upgrade with attached nxdbmgr.exe.

Best regards,
Victor

Luiz A. Camilo

I tryed again and used the executable that you provided me, and got an error again ... on another step ...

C:\NetXMS\bin>nxdbmgr upgrade -t
NetXMS Database Manager Version 0.2.23-rc1

Configuration file OK
Upgrading database...
Upgrading from version 80 to 81
>>> SELECT item_id,schedule FROM dci_schedules
>>> DROP TABLE dci_schedules
>>> CREATE TABLE dci_schedules (schedule_id integer not null,item_id integer not
null,schedule varchar(255) not null,PRIMARY KEY(item_id,schedule_id))
>>> ALTER TABLE address_lists ADD PRIMARY KEY (list_type,community_id,addr_type,
addr1,addr2)
SQL query failed (General SQL Server error: Check messages from the SQL Server.)
:
ALTER TABLE address_lists ADD PRIMARY KEY (list_type,community_id,addr_type,addr
1,addr2)
Rolling back last stage due to upgrade errors...
Database upgrade failed

When executing the command from query analyzer, the error is bellow .

Server: Msg 8111, Level 16, State 1, Line 1
Cannot define PRIMARY KEY constraint on nullable column in table 'address_lists'.
Server: Msg 1750, Level 16, State 1, Line 1
Could not create constraint. See previous errors.

Can you give me the full upgrade script that you´re using on this executable ?
I can try to work on it .. , as seems that I´m the only one having problems to upgrade ...



Victor Kirhenshtein

Hello!

It's not a plain SQL script. Commands may vary between databases, so it's a set of static and dynamically created SQL queries encoded into nxdbmgr code.

I change the upgrade code to re-create tables instead of adding constraints, hopefully it will work.

Attached is a latest version of nxdbmgr.exe.

Best regards,
Victor