﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35180	PostgreSQL pattern ops indexes are dropped when changing between CharField and TextField	Robin Ray	bcail	"When converting an indexed CharField to a TextField (and vice versa) on PostgreSQL, Django drops the existing pattern ops `_like` index for the column but does not recreate it with the new pattern ops. When reversing the migration, Django does not recreate the initial `_like` index.

I have been able to reproduce this behavior in Django 3.2 and 5.0.

**Reproduction**

1. Given a model with a CharField that has `db_index=True` on a PostgreSQL database
2. Inspect the database indexes or migration SQL and see that the indexed CharField has two indexes, one of which ends in `_like` and uses `varchar_pattern_ops`
3. Change the CharField to a TextField and generate a migration
4. Run the migration or inspect the SQL with the `sqlmigrate` manage command
5. Inspect the database indexes or migration SQL and see that the indexed TextField does not have a `_like` index
6. Reverse the migration
7. Inspect the database indexes or migration SQL and see that the indexed CharField no longer has a `_like` index

Here is an example project that demonstrates the issue: https://github.com/robin-ray/alter_text_index_repro"	Bug	closed	Database layer (models, ORM)	dev	Normal	fixed	index postgres migration	Simon Charette Mariusz Felisiak bcail	Ready for checkin	1	0	0	0	0	0
