From 8034e6a881ee244c97537732939c09a6b883f0f7 Mon Sep 17 00:00:00 2001 From: Mariano ramirez Date: Mon, 16 Feb 2026 13:07:07 -0400 Subject: [PATCH] Update settings.py to clarify indexing support for TextFields in PostgreSQL and MySQL, and adjust default behavior for INDEX_SEARCH_NAMES. --- .../0014_alter_city_search_names.py | 19 +++++++++++++++++++ src/cities_light/settings.py | 16 ++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 src/cities_light/migrations/0014_alter_city_search_names.py diff --git a/src/cities_light/migrations/0014_alter_city_search_names.py b/src/cities_light/migrations/0014_alter_city_search_names.py new file mode 100644 index 00000000..8ec47f6d --- /dev/null +++ b/src/cities_light/migrations/0014_alter_city_search_names.py @@ -0,0 +1,19 @@ +# Generated by Django 6.0.2 on 2026-02-16 17:06 + +import cities_light.abstract_models +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('cities_light', '0013_alter_city_alternate_names_alter_city_country_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='city', + name='search_names', + field=cities_light.abstract_models.ToSearchTextField(blank=True, default='', max_length=4000, verbose_name='search names'), + ), + ] diff --git a/src/cities_light/settings.py b/src/cities_light/settings.py index c0313d22..4e9e6c5a 100644 --- a/src/cities_light/settings.py +++ b/src/cities_light/settings.py @@ -89,8 +89,7 @@ using several databases for your project. Notes: - - MySQL doesn't support indexing TextFields. - - PostgreSQL supports indexing TextFields, but it is not enabled by default + - PostgreSQL and MySQL supports indexing TextFields, but it is not enabled by default in cities_light because the lenght of the field can be too long for btree for more information please visit #273 @@ -200,16 +199,9 @@ ], ) -# MySQL doesn't support indexing TextFields -INDEX_SEARCH_NAMES = getattr(settings, "CITIES_LIGHT_INDEX_SEARCH_NAMES", None) -if INDEX_SEARCH_NAMES is None: - INDEX_SEARCH_NAMES = True - for database in list(settings.DATABASES.values()): - if "ENGINE" in database and ( - "mysql" in database.get("ENGINE").lower() - or "postgresql" in database.get("ENGINE").lower() - ): - INDEX_SEARCH_NAMES = False + +INDEX_SEARCH_NAMES = getattr(settings, "CITIES_LIGHT_INDEX_SEARCH_NAMES", False) + DEFAULT_APP_NAME = "cities_light" CITIES_LIGHT_APP_NAME = getattr(settings, "CITIES_LIGHT_APP_NAME", DEFAULT_APP_NAME)