Test reworking migration for mysql/postgresql
This commit is contained in:
parent
fbbe4bd19b
commit
604a1b6a66
1 changed files with 31 additions and 16 deletions
|
|
@ -9,19 +9,34 @@ class Migration(migrations.Migration):
|
||||||
("typeclasses", "0016_alter_attribute_id_alter_tag_id"),
|
("typeclasses", "0016_alter_attribute_id_alter_tag_id"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
def get_operations(self, app_labels, schema_editor):
|
||||||
# First create the index with the old name that Django expects
|
"""Return database-specific operations"""
|
||||||
migrations.AddIndex(
|
if schema_editor.connection.vendor == "sqlite":
|
||||||
model_name="tag",
|
# For SQLite, we know the two-step process works
|
||||||
index=models.Index(
|
return [
|
||||||
fields=["db_key", "db_category", "db_tagtype", "db_model"],
|
migrations.AddIndex(
|
||||||
name="typeclasses_tag_db_key_db_category_db_tagtype_db_model_idx",
|
model_name="tag",
|
||||||
),
|
index=models.Index(
|
||||||
),
|
fields=["db_key", "db_category", "db_tagtype", "db_model"],
|
||||||
# Then rename it to the new name
|
name="typeclasses_tag_db_key_db_category_db_tagtype_db_model_idx",
|
||||||
migrations.RenameIndex(
|
),
|
||||||
model_name="tag",
|
),
|
||||||
new_name="typeclasses_db_key_be0c81_idx",
|
migrations.RenameIndex(
|
||||||
old_fields=("db_key", "db_category", "db_tagtype", "db_model"),
|
model_name="tag",
|
||||||
),
|
new_name="typeclasses_db_key_be0c81_idx",
|
||||||
]
|
old_fields=("db_key", "db_category", "db_tagtype", "db_model"),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
# For other databases, create the index directly with its final name
|
||||||
|
return [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name="tag",
|
||||||
|
index=models.Index(
|
||||||
|
fields=["db_key", "db_category", "db_tagtype", "db_model"],
|
||||||
|
name="typeclasses_db_key_be0c81_idx",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [] # Will be populated at runtime by get_operations()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue