From 0789f71e1795d3c94e290e5335ee930171d77845 Mon Sep 17 00:00:00 2001
From: Kirill Solomko <ksolomko@sipwise.com>
Date: Fri, 17 Nov 2023 00:06:07 +0100
Subject: [PATCH] MT#58768 fix voip_allowed_ip_groups.ipnet column

There are 2 .up scripts that modify voip_allowed_ip_groups.ipnet
15702.up - modifies it to varchar(43)
15710.up - modifies it to varchar(46)
Because in 15710.up was backported into mr9.5 but is missing in mr10.5,
existing upgrades from mr9.5 -> mr10.5 apply 15702 after 15710.up,
effectively downgrading the column to varchar(46).

This .up script fixes the scenario and also the .down script modifies
the column also to varchar(46) to respect the previous 15710.up the
sets it to varchar(46), so to achieve the consistent state.

Change-Id: If14917ef437de3abf46b1900f68c9cc3a9a4b947
(cherry picked from commit 9c6ef86372a6fc95c350146a7e4938584f995b62)
---
 db_scripts/diff/15790.down | 4 ++++
 db_scripts/diff/15790.up   | 2 ++
 2 files changed, 6 insertions(+)
 create mode 100644 db_scripts/diff/15790.down
 create mode 100644 db_scripts/diff/15790.up

diff --git a/db_scripts/diff/15790.down b/db_scripts/diff/15790.down
new file mode 100644
index 00000000..a2745166
--- /dev/null
+++ b/db_scripts/diff/15790.down
@@ -0,0 +1,4 @@
+use provisioning;
+# this is a fixup and the column was already supposed to be varchar(46), therefore,
+# bringing it back to the state it comes with in 15710.up
+alter table voip_allowed_ip_groups modify column ipnet varchar(46) not null;
diff --git a/db_scripts/diff/15790.up b/db_scripts/diff/15790.up
new file mode 100644
index 00000000..fb8d7c61
--- /dev/null
+++ b/db_scripts/diff/15790.up
@@ -0,0 +1,2 @@
+use provisioning;
+alter table voip_allowed_ip_groups modify column ipnet varchar(46) not null;