Commit 1fca15ad7a for asterisk.org
commit 1fca15ad7a26128e12c1820d97748e350cc5b469
Author: George Joseph <gjoseph@sangoma.com>
Date: Thu Sep 17 06:58:52 2026 -0600
res_geolocation: Fix alembic scripts for MySQL.
Depending on the backend storage type, MySQL rows could have a maximum
length of 65535 bytes including storage overhead. The number and size of
the fixed-size string columns in the geoloc_profile table cause this to
be exceeded. Unfortunately, this isn't detected until you try to
actually create the table. To address this, the string columns types
have been changed to TEXT, which both MySQL and PostgreSQL handle
without counting to maximum row size. For long, variable-length strings,
TEXT is also more storage efficient.
MySQL also had an issue with the way the Enums were created. These
were also fixed.
diff --git a/contrib/ast-db-manage/config/versions/2b45fd748a4f_add_geolocation_tables.py b/contrib/ast-db-manage/config/versions/2b45fd748a4f_add_geolocation_tables.py
index 232ab574e9..1d0c97c678 100644
--- a/contrib/ast-db-manage/config/versions/2b45fd748a4f_add_geolocation_tables.py
+++ b/contrib/ast-db-manage/config/versions/2b45fd748a4f_add_geolocation_tables.py
@@ -30,40 +30,45 @@ GEOLOC_PROFILE_PRECEDENCE_NAME = 'geoloc_profile_precedence_values'
GEOLOC_PROFILE_PRECEDENCE_VALUES = ['prefer_incoming', 'prefer_config', 'discard_incoming','discard_config']
def upgrade():
- enum_format = ENUM(*GEOLOC_LOCATION_FORMAT_VALUES, name=GEOLOC_LOCATION_FORMAT_NAME, checkfirst=True)
- enum_pidf_element = ENUM(*GEOLOC_PROFILE_PIDF_ELEMENT_VALUES, name=GEOLOC_PROFILE_PIDF_ELEMENT_NAME, checkfirst=True)
- enum_precedence = ENUM(*GEOLOC_PROFILE_PRECEDENCE_VALUES, name=GEOLOC_PROFILE_PRECEDENCE_NAME, checkfirst=True)
+ enum_format = sa.Enum(*GEOLOC_LOCATION_FORMAT_VALUES, name=GEOLOC_LOCATION_FORMAT_NAME)
+ enum_pidf_element = sa.Enum(*GEOLOC_PROFILE_PIDF_ELEMENT_VALUES, name=GEOLOC_PROFILE_PIDF_ELEMENT_NAME)
+ enum_precedence = sa.Enum(*GEOLOC_PROFILE_PRECEDENCE_VALUES, name=GEOLOC_PROFILE_PRECEDENCE_NAME)
ast_bool_values = ENUM(*AST_BOOL_VALUES, name=AST_BOOL_NAME, create_type=False)
+#
+# The use of the 'TEXT' column type instead of 'String' for the string data columns
+# is deliberate. Many of the columns can be very long (>= 2048) and if defined as
+# 'String(n)' would add up to more than the maximum row size (65535) for MySql.
+#
op.create_table(
'geoloc_location',
sa.Column('id', sa.String(80), nullable=False, primary_key=True),
sa.Column('format', enum_format, nullable=True),
- sa.Column('location_info', sa.String(2048), nullable=True),
- sa.Column('location_source', sa.String(1024), nullable=True),
- sa.Column('confidence', sa.String(2048), nullable=True),
- sa.Column('method', sa.String(2048), nullable=True)
+ sa.Column('location_info', sa.TEXT, nullable=True),
+ sa.Column('location_source', sa.TEXT, nullable=True),
+ sa.Column('confidence', sa.TEXT, nullable=True),
+ sa.Column('method', sa.TEXT, nullable=True)
)
op.create_table(
'geoloc_profile',
sa.Column('id', sa.String(80), nullable=False, primary_key=True),
sa.Column('pidf_element', enum_pidf_element, nullable=True),
- sa.Column('pidf_element_id', sa.String(80), nullable=True),
- sa.Column('device_id', sa.String(1024), nullable=True),
- sa.Column('location_reference', sa.String(80), nullable=True),
- sa.Column('location_info_refinement', sa.String(2048), nullable=True),
- sa.Column('location_variables', sa.String(2048), nullable=True),
- sa.Column('usage_rules', sa.String(2048), nullable=True),
- sa.Column('notes', sa.String(2048), nullable=True),
+ sa.Column('pidf_element_id', sa.TEXT, nullable=True),
+ sa.Column('device_id', sa.TEXT, nullable=True),
+ sa.Column('location_reference', sa.TEXT, nullable=True),
+ sa.Column('location_info_refinement', sa.TEXT, nullable=True),
+ sa.Column('location_variables', sa.TEXT, nullable=True),
+ sa.Column('usage_rules', sa.TEXT, nullable=True),
+ sa.Column('notes', sa.TEXT, nullable=True),
sa.Column('allow_routing_use', ast_bool_values),
sa.Column('suppress_empty_ca_elements', ast_bool_values),
sa.Column('profile_precedence', enum_precedence, nullable=True),
sa.Column('format', enum_format, nullable=True),
- sa.Column('location_info', sa.String(2048), nullable=True),
- sa.Column('location_source', sa.String(1024), nullable=True),
- sa.Column('confidence', sa.String(2048), nullable=True),
- sa.Column('method', sa.String(2048), nullable=True)
+ sa.Column('location_info', sa.TEXT, nullable=True),
+ sa.Column('location_source', sa.TEXT, nullable=True),
+ sa.Column('confidence', sa.TEXT, nullable=True),
+ sa.Column('method', sa.TEXT, nullable=True)
)
def downgrade():