[FAIL] ./lnms migrate

Hello

I’m having issues when running validate.php it states that my database is out of date , this can be fixed by running ./lnms migrate.

:~$ ./validate.php

Component Version
LibreNMS 21.3.0-46-g10cf97e58
DB Schema 2021_03_11_003540_rename_toner_table (202)
PHP 7.4.3
Python 3.8.5
MySQL 10.3.25-MariaDB-0ubuntu0.20.04.1
RRDTool 1.7.2
SNMP NET-SNMP 5.8
====================================

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

But after running the migrate command I get these errors .

~$ ./lnms migrate --pretend


  • Application In Production!     *
    

Do you really wish to run this command? (yes/no) [no]:

yes

MigrateToUtf8mb4: ALTER SCHEMA librenms DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
MigrateToUtf8mb4: select TABLE_NAME from information_schema.tables where table_schema = ?
MigrateToUtf8mb4: select * from information_schema.columns where table_schema = ? and CHARACTER_SET_NAME is not null and COLLATION_NAME is not null and (CHARACTER_SET_NAME != ? or COLLATION_NAME != ?)

In SchemaException.php line 86:

There is no column with name ‘supply_descr’ on table ‘printer_supplies’.

I’d appreciate any help you can provide
Thanks

1 Like

I am having the same issue.

Validate.php giving me the error

====================================
Component | Version
--------- | -------
LibreNMS  | 21.4.0
DB Schema | 2020_12_14_091314_create_port_group_port_table (202)
PHP       | 7.4.16
Python    | 3.6.8
MySQL     | 10.5.9-MariaDB
RRDTool   | 1.4.8
SNMP      | NET-SNMP 5.7.2
====================================

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

But then I get below error when I run

'runuser -u librenms – /opt/librenms/lnms migrate --pretend ’

**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

CreatePortGroupsTable: create table `port_groups` (`id` int unsigned not null auto_increment primary key, `name` varchar(255) not null, `desc` varchar(255) null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'
CreatePortGroupsTable: alter table `port_groups` add unique `port_groups_name_unique`(`name`)
MigrateToUtf8mb4: ALTER SCHEMA `librenms` DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci;
MigrateToUtf8mb4: select `TABLE_NAME` from `information_schema`.`tables` where `table_schema` = ?
MigrateToUtf8mb4: select * from `information_schema`.`columns` where `table_schema` = ? and `CHARACTER_SET_NAME` is not null and `COLLATION_NAME` is not null and (`CHARACTER_SET_NAME` != ? or `COLLATION_NAME` != ?)
RenameTonerTable: rename table `toner` to `printer_supplies`

In SchemaException.php line 86:
                                                                            
  There is no column with name 'supply_descr' on table 'printer_supplies'.

I have never added any printer to monitor. and when I go into the database this is the printer_supplies table:

MariaDB [librenms]> select * from printer_supplies limit 5;    
Empty set (0.00 sec)

Do I have to add a printer or something?

Hey @condor ,

I have solved the issue:

ALTER TABLE printer_supplies ADD supply_descr varchar(10) AFTER toner_capacity_oid;

by adding the column above.

Thanks, I have ended up doing the same but was hoping there is a script to fix this.

I’m having a version of this also:

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

Component Version
LibreNMS 21.4.0
DB Schema 2020_12_14_091314_create_port_group_port_table (462)
PHP 7.4.6
Python 3.5.3
MySQL 10.3.27-MariaDB-0+deb10u1
RRDTool 1.6.0
SNMP NET-SNMP 5.7.3
====================================

[OK] Composer Version: 2.0.12
[OK] Dependencies up-to-date.
[OK] Database connection successful
[FAIL] Your database is out of date!
[FIX]:
./lnms migrate
[INFO] Detected Python Wrapper
[OK] Connection to memcached is ok
librenms@librenms:~$ ./lnms migrate


  • Application In Production!     *
    

Do you really wish to run this command? (yes/no) [no]:

yes

Migrating: 2020_12_14_091314_create_port_groups_table

In Connection.php line 678:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists (SQL: create table port_groups (id int unsigned not null auto_increment primary key, name varchar(255) not null, desc varchar(255) nu
ll) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)

In Exception.php line 18:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

In PDOStatement.php line 112:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

I followed this to get my DB to 10.5 (make sure to backup all sql before upgrading) and fix the port_groups error Database out of date - validate.php - lnms update

best check port_groups is empty before dropping

lmns migrate will then work (took 10 minutes to run for me)

I am having the same issue.

My Table looks like this.

MariaDB [librenms]> describe printer_supplies;
±-------------------±-----------------±-----±----±--------±---------------+
| Field | Type | Null | Key | Default | Extra |
±-------------------±-----------------±-----±----±--------±---------------+
| toner_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| device_id | int(10) unsigned | NO | MUL | 0 | |
| toner_index | int(11) | NO | | NULL | |
| toner_type | varchar(64) | NO | | NULL | |
| toner_oid | varchar(64) | NO | | NULL | |
| toner_descr | varchar(255) | NO | | | |
| toner_capacity | int(11) | NO | | 0 | |
| toner_current | int(11) | NO | | 0 | |
| toner_capacity_oid | varchar(64) | YES | | NULL | |
| supply_descr | varchar(10) | YES | | NULL | |
±-------------------±-----------------±-----±----±--------±---------------+
10 rows in set (0.001 sec)

./lnms migrate --pretend

RenamePrinterColumns: ALTER TABLE printer_supplies CHANGE toner_id supply_id INT UNSIGNED AUTO_INCREMENT NOT NULL
RenamePrinterColumns: ALTER TABLE printer_supplies CHANGE toner_index supply_index INT NOT NULL
RenamePrinterColumns: ALTER TABLE printer_supplies CHANGE toner_type supply_type VARCHAR(64) NOT NULL
RenamePrinterColumns: ALTER TABLE printer_supplies CHANGE toner_oid supply_oid VARCHAR(64) NOT NULL
RenamePrinterColumns: ALTER TABLE printer_supplies CHANGE toner_descr supply_descr VARCHAR(255) DEFAULT ‘’ NOT NULL
RenamePrinterColumns: ALTER TABLE printer_supplies CHANGE toner_capacity supply_capacity INT DEFAULT 0 NOT NULL
RenamePrinterColumns: ALTER TABLE printer_supplies CHANGE toner_current supply_current INT DEFAULT 0 NOT NULL
RenamePrinterColumns: ALTER TABLE printer_supplies CHANGE toner_capacity_oid supply_capacity_oid VARCHAR(64) DEFAULT NULL
RenamePrinterColumns: ALTER TABLE printer_supplies CHANGE supply_descr supply_descr VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE utf8mb4_unicode_ci
ChangeCacheToMediumtext: ALTER TABLE cache CHANGE value value MEDIUMTEXT CHARACTER SET utf8mb4 NOT NULL COLLATE utf8mb4_unicode_ci

But when i run ./lnms migrate

Migrating: 2021_03_11_003713_rename_printer_columns

In Connection.php line 678:

SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name ‘supply_descr’ (SQL: ALTER TABLE printer_supplies CHANGE toner_descr supply_descr VARCHAR(255) DEFAULT ‘’ NOT NULL)

In Exception.php line 18:

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

In PDOStatement.php line 112:

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

Can someone please help.

Bhargav

Hi @bhaggu,
Did you solve your problem?
I have the same error message than you while processing the “2021_03_11_003713_rename_printer_columns” migration DB Schema.
Regards

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