Database Upadate Table issue Missing table. Manually recreate tables

I am trying to update the MariaDB as per the latest release of LibreNMS. However during update something went wrong and the NMS is down now. Few details are as follows.

bash-4.2$ ./daily.sh
Fetching new release information OK
Updating to latest release OK
Updating Composer packages OK
Updating SQL-Schema OK
Updating submodules OK
Cleaning up DB OK
Fetching notifications OK
Caching PeeringDB data OK
bash-4.2$ ./validate.php

Component Version
LibreNMS 21.4.0
DB Schema 2021_02_09_122930_migrate_to_utf8mb4 (204)
PHP 7.4.12
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
bash-4.2$ ./lnms migrate


  • Application In Production!     *
    

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

yes

Migrating: 2021_03_11_003540_rename_toner_table

In Connection.php line 678:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.toner’ doesn’t exist (SQL: rename table toner to printer_supplies)

In Exception.php line 18:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.toner’ doesn’t exist

In PDOStatement.php line 112:

SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘librenms.toner’ doesn’t exist

bash-4.2$ ./lnms migrate --pretend


  • Application In Production!     *
    

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

yes

RenameTonerTable: rename table toner to printer_supplies

In SchemaException.php line 86:

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

bash-4.2$

While checking the Database, I found that “printer_supplies” or “toner” table is not there at all. Can someone help me provide command to create the table again. ( I am not DB or Linux expert ) Moreover there is a missing “Syslog” table as well.

Can someone provide the commands to recreate those tables, so I can move ahead in migration / troubleshoot .

Bhargav

i’m having the same issue. anyone can help?

Same issue here.

mi librebnms had same issue, and I cannot login

Yeah somehow an update was pushed that scrozzled all of us. I am in the same boat.

This workaround to manually recreate the toner table got us going again. We don’t store toner/printer info in our instance, so having an empty table is no big deal.

  1. Make sure you don’t have either the toner or the printer_supplies table

librenms:~$ mysql -ulibrenms -p
Enter password:
then
use librenms;
show tables;

If you see printer_supplies, you can ALTER the table name to toner (alter table printer_supplies rename to toner;) and rerun lnms_migrate

  1. Pull the create table toner from the database schema file from source code:
    https://github.com/librenms/librenms/blob/master/database/schema/mysql-schema.dump
    Currently, it looks like this:
    DROP TABLE IF EXISTS toner;
    /*!40101 SET @saved_cs_client = @@character_set_client /;
    /
    !40101 SET character_set_client = utf8 /;
    CREATE TABLE toner (
    toner_id int(10) unsigned NOT NULL AUTO_INCREMENT,
    device_id int(10) unsigned NOT NULL DEFAULT ‘0’,
    toner_index int(11) NOT NULL,
    toner_type varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
    toner_oid varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
    toner_descr varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ‘’,
    toner_capacity int(11) NOT NULL DEFAULT ‘0’,
    toner_current int(11) NOT NULL DEFAULT ‘0’,
    toner_capacity_oid varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    PRIMARY KEY (toner_id),
    KEY toner_device_id_index (device_id)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    /
    !40101 SET character_set_client = @saved_cs_client */;

  2. Paste this into the mysql CLI. Do a ’ show tables;’ and you should now see a toner table. quit the mysql CLI.

  3. librenms:~$ ./lnms migrate

Hope this helps…