From eedb965b8767d5b0e3e0e7a1776a4bdc83e0088b Mon Sep 17 00:00:00 2001 From: Joseph Tibbertsma Date: Tue, 3 Sep 2024 08:46:27 -0700 Subject: [PATCH] Add index migration --- .../0003_add_cast_index_on_object_id.py | 2 +- .../0004_add_index_recover_optimization.py | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 reversion/migrations/0004_add_index_recover_optimization.py diff --git a/reversion/migrations/0003_add_cast_index_on_object_id.py b/reversion/migrations/0003_add_cast_index_on_object_id.py index 840b1b37..b57fbecb 100644 --- a/reversion/migrations/0003_add_cast_index_on_object_id.py +++ b/reversion/migrations/0003_add_cast_index_on_object_id.py @@ -1,4 +1,4 @@ -# Generated manually lol +# Generated manually from django.db import migrations diff --git a/reversion/migrations/0004_add_index_recover_optimization.py b/reversion/migrations/0004_add_index_recover_optimization.py new file mode 100644 index 00000000..5443b2d9 --- /dev/null +++ b/reversion/migrations/0004_add_index_recover_optimization.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.15 on 2024-09-01 17:23 + +from django.db import migrations + + +class Migration(migrations.Migration): + atomic = False + + dependencies = [ + ("reversion", "0003_add_cast_index_on_object_id"), + ] + + operations = [ + migrations.RunSQL( + sql=""" +CREATE INDEX CONCURRENTLY IF NOT EXISTS "reversion_version_recover_optimization" ON +"reversion_version" (content_type_id, db, object_id, id DESC); + """, + reverse_sql=""" +DROP INDEX CONCURRENTLY IF EXISTS "reversion_version_recover_optimization"; +""", + elidable=False, + ), + ]