From df46a77cd95497a31f32b3f5852459d2533bfcfe Mon Sep 17 00:00:00 2001 From: William Edwards Date: Sat, 4 Nov 2023 20:37:53 +0100 Subject: [PATCH] Increase max package name length to 128 characters (#14895) * Increase max package name length to 80 characters One of my packages has a name of 65 characters. LibreNMS limits package names to 64 characters (`varchar(64) NOT NULL`). As the name of my package is truncated, polling fails with the following error: ``` Error polling unix-agent module for http-jglt01.gmdo.ha.cyberfusion.cloud. PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '458-python3-cyberfusion-cluster-configurations-redirect-fast-...' for key 'packages_device_id_name_manager_arch_version_build_unique' in /opt/librenms/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117 ``` There is no well-defined max package name length. An email on the `debian-devel` mailing list (https://lists.debian.org/debian-devel/2011/04/msg00981.html) states that the length of package names should not exceed 40 characters, and that the length of file names should not exceed 90 characters, but these limits are not enforced. Lintian does not check package name length, but does check that file name length does not exceed 80 characters (tag 'package-has-long-file-name'). Summarised: there are no well-defined and enforced limits, and those that Lintian advices differ from the aforementioned post on the `debian-devel` mailing list. Therefore, I have landed on the semi-random limit of 80 characters (which the original limit of 64 characters seems to be as well). * Create 2023_11_04_125846_packages_increase_name_column_length.php * Update db_schema.yaml --------- Co-authored-by: Tony Murray --- ...6_packages_increase_name_column_length.php | 28 +++++++++++++++++++ misc/db_schema.yaml | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2023_11_04_125846_packages_increase_name_column_length.php diff --git a/database/migrations/2023_11_04_125846_packages_increase_name_column_length.php b/database/migrations/2023_11_04_125846_packages_increase_name_column_length.php new file mode 100644 index 0000000000..228e851b07 --- /dev/null +++ b/database/migrations/2023_11_04_125846_packages_increase_name_column_length.php @@ -0,0 +1,28 @@ +string('name', 128)->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('packages', function (Blueprint $table) { + $table->string('name', 64)->change(); + }); + } +}; diff --git a/misc/db_schema.yaml b/misc/db_schema.yaml index 0525254b4c..d5e5865800 100644 --- a/misc/db_schema.yaml +++ b/misc/db_schema.yaml @@ -1345,7 +1345,7 @@ packages: Columns: - { Field: pkg_id, Type: 'int unsigned', 'Null': false, Extra: auto_increment } - { Field: device_id, Type: 'int unsigned', 'Null': false, Extra: '' } - - { Field: name, Type: varchar(64), 'Null': false, Extra: '' } + - { Field: name, Type: varchar(128), 'Null': false, Extra: '' } - { Field: manager, Type: varchar(16), 'Null': false, Extra: '', Default: '1' } - { Field: status, Type: tinyint, 'Null': false, Extra: '' } - { Field: version, Type: varchar(255), 'Null': false, Extra: '' }