Error on ./lnms migrate

====================================
Component | Version
--------- | -------
LibreNMS | 21.6.0-8-g748186c05
DB Schema | 2021_03_11_003540_rename_toner_table (204)
PHP | 7.4.20
Python | 3.6.9
MySQL | 10.5.10-MariaDB-1:10.5.10+maria~bionic
RRDTool | 1.7.0
SNMP | NET-SNMP 5.7.3
====================================

[OK] Composer Version: 2.1.3
[OK] Dependencies up-to-date.
[OK] Database connection successful
[FAIL] Your database is out of date!
[FIX]:
./lnms migrate

====================================================

Hi, i’m stuck with this error:

In SchemaException.php line 86:
There is no column with name ‘toner_id’ on table ‘printer_supplies’.

Droped Printer_supplies table and recreated toner table, nothing changes.

I also run the table update procees manually

rename table toner to printer_supplies;
ALTER TABLE printer_supplies CHANGE toner_id supply_id INT UNSIGNED AUTO_INCREMENT NOT NULL;*
ALTER TABLE printer_supplies CHANGE toner_index supply_index INT NOT NULL;
ALTER TABLE printer_supplies CHANGE toner_type supply_type VARCHAR(64) NOT NULL;
ALTER TABLE printer_supplies CHANGE toner_oid supply_oid VARCHAR(64) NOT NULL;
ALTER TABLE printer_supplies CHANGE toner_descr supply_descr VARCHAR(32) DEFAULT ‘’ NOT NULL;
ALTER TABLE printer_supplies CHANGE toner_capacity supply_capacity INT DEFAULT 0 NOT NULL;
ALTER TABLE printer_supplies CHANGE toner_current supply_current INT DEFAULT 0 NOT NULL;
ALTER TABLE printer_supplies CHANGE toner_capacity_oid supply_capacity_oid VARCHAR(64) DEFAULT NULL;
ALTER TABLE printer_supplies CHANGE supply_descr supply_descr VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE utf8mb4_unicode_ci;

MariaDB [librenms]> desc printer_supplies;
±--------------------±-----------------±-----±----±--------±---------------+
| Field | Type | Null | Key | Default | Extra |
±--------------------±-----------------±-----±----±--------±---------------+
| supply_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| device_id | int(10) unsigned | NO | MUL | 0 | |
| supply_index | int(11) | NO | | NULL | |
| supply_type | varchar(64) | NO | | NULL | |
| supply_oid | varchar(64) | NO | | NULL | |
| supply_descr | varchar(255) | YES | | NULL | |
| supply_capacity | int(11) | NO | | 0 | |
| supply_current | int(11) | NO | | 0 | |
| supply_capacity_oid | varchar(64) | YES | | NULL | |
±--------------------±-----------------±-----±----±--------±---------------+

The same error message is showed runing the migration.

In SchemaException.php line 86:
There is no column with name ‘toner_id’ on table ‘printer_supplies’.

There is any way to remove this table conversion from the process or something that i can do to complete the migration?

Thanks in advance!

Hi I finally complete migration 2021_03_11_003713_rename_printer_columns
Migrated: 2021_03_11_003713_rename_printer_columns (2,665.37ms)

The new issue is at the next one

Migrating: 2021_03_17_160729_service_templates_cleanup

In Connection.php line 678:

SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name ‘check’ (SQL: ALTER TABLE service_templates CHANGE type check VARCHAR(16) DEFAULT
‘static’ NOT NULL)

In Exception.php line 18:

SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name ‘check’

In PDOStatement.php line 112:

SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name ‘check’

Where I can found sql statment to run it manually?

Thanks!

Hi Solution to the last error.

Drop and Rebuild the tables service_templates_device_group; service_templates_device; service_templates according to the last DB Schema.

Then manually update the migration table

INSERT INTO migrations (migration, batch) VALUES (‘2021_03_17_160729_service_templates_cleanup’,‘7’); (Use the next batch number avaliable)

Then run ./lnms migration.

After run ./validate.php, you will get some errores.

Fix them runing the ./validate.php output statment at mariadb.

ALTER TABLE service_templates ADD check varchar(255) NOT NULL AFTER ip;
ALTER TABLE service_templates CHANGE type type varchar(16) NOT NULL DEFAULT ‘static’ ;
ALTER TABLE service_templates ADD rules text NULL AFTER type;
ALTER TABLE service_templates DROP dtype;
ALTER TABLE service_templates DROP dgtype;
ALTER TABLE service_templates DROP drules;
ALTER TABLE service_templates DROP dgrules;

and voila!

====================================

Component Version
LibreNMS 21.6.0-25-ge27403fc2
DB Schema 2021_25_01_0127_create_isis_adjacencies_table (211)
PHP 7.4.20
Python 3.6.9
MySQL 10.5.10-MariaDB-1:10.5.10+maria~bionic
RRDTool 1.7.0
SNMP NET-SNMP 5.7.3

====================================

[OK] Composer Version: 2.1.3
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.