Skip to content

Commit

Permalink
Experiment with indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Kubov committed Jul 5, 2024
1 parent d2b5c7e commit 59933d9
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion pymess/migrations/0030_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,41 @@ class Migration(migrations.Migration):
new_name='template_old',
),

# We add indexes to speed-up insertion.

migrations.AddIndex(
model_name='dialermessage',
index=models.Index(fields=['template_old'], name='pymess_dial_templat_8f8f2d_idx'),
),
migrations.AddIndex(
model_name='dialertemplatedisallowedobject',
index=models.Index(fields=['template_old'], name='pymess_dial_templat_94e496_idx'),
),
migrations.AddIndex(
model_name='emailmessage',
index=models.Index(fields=['template_old'], name='pymess_emai_templat_751e5f_idx'),
),
migrations.AddIndex(
model_name='emailtemplateattachment',
index=models.Index(fields=['template_old'], name='pymess_emai_templat_1e5760_idx'),
),
migrations.AddIndex(
model_name='emailtemplatedisallowedobject',
index=models.Index(fields=['template_old'], name='pymess_emai_templat_799bce_idx'),
),
migrations.AddIndex(
model_name='outputsmsmessage',
index=models.Index(fields=['template_old'], name='pymess_outp_templat_f4eb8d_idx'),
),
migrations.AddIndex(
model_name='pushnotificationmessage',
index=models.Index(fields=['template_old'], name='pymess_push_templat_8d32eb_idx'),
),
migrations.AddIndex(
model_name='smstemplatedisallowedobject',
index=models.Index(fields=['template_old'], name='pymess_smst_templat_1a34e4_idx'),
),

# 3. Slug is no longer a primary key.

migrations.AlterField(
Expand Down Expand Up @@ -273,7 +308,40 @@ class Migration(migrations.Migration):

migrations.RunPython(create_template_ids_from_slugs),

# 8. We can safely remove old `template_old` field.
# 8. We can safely remove old `template_old` fields and their indexes.

migrations.RemoveIndex(
model_name='dialermessage',
name='pymess_dial_templat_8f8f2d_idx',
),
migrations.RemoveIndex(
model_name='dialertemplatedisallowedobject',
name='pymess_dial_templat_94e496_idx',
),
migrations.RemoveIndex(
model_name='emailmessage',
name='pymess_emai_templat_751e5f_idx',
),
migrations.RemoveIndex(
model_name='emailtemplateattachment',
name='pymess_emai_templat_1e5760_idx',
),
migrations.RemoveIndex(
model_name='emailtemplatedisallowedobject',
name='pymess_emai_templat_799bce_idx',
),
migrations.RemoveIndex(
model_name='outputsmsmessage',
name='pymess_outp_templat_f4eb8d_idx',
),
migrations.RemoveIndex(
model_name='pushnotificationmessage',
name='pymess_push_templat_8d32eb_idx',
),
migrations.RemoveIndex(
model_name='smstemplatedisallowedobject',
name='pymess_smst_templat_1a34e4_idx',
),

migrations.RemoveField(
model_name='dialertemplatedisallowedobject',
Expand Down

0 comments on commit 59933d9

Please sign in to comment.