Skip to content

Commit 0cd6824

Browse files
authored
fix: make concurrent index migrations idempotent (baserow#5234)
1 parent 87ccd86 commit 0cd6824

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Generated by Django 5.2.12 on 2026-03-17 09:16
22

33
from django.db import migrations, models
4-
from django.contrib.postgres.operations import AddIndexConcurrently
54

65

76
class Migration(migrations.Migration):
@@ -12,8 +11,14 @@ class Migration(migrations.Migration):
1211
]
1312

1413
operations = [
15-
AddIndexConcurrently(
16-
model_name='rowhistory',
17-
index=models.Index(fields=['action_timestamp'], name='database_ro_action__6ea699_idx'),
14+
migrations.RunSQL(
15+
sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "database_ro_action__6ea699_idx" ON "database_rowhistory" ("action_timestamp")',
16+
reverse_sql='DROP INDEX IF EXISTS "database_ro_action__6ea699_idx"',
17+
state_operations=[
18+
migrations.AddIndex(
19+
model_name='rowhistory',
20+
index=models.Index(fields=['action_timestamp'], name='database_ro_action__6ea699_idx'),
21+
),
22+
],
1823
),
1924
]

backend/src/baserow/core/migrations/0113_alter_notification_options_and_more.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Migration(migrations.Migration):
3131
name='core_notifi_created_06e5e6_idx',
3232
),
3333
migrations.RunSQL(
34-
sql='CREATE INDEX CONCURRENTLY "core_notifi_created_7f4b88_idx" ON "core_notification" ("created_on" DESC, "id" DESC)',
34+
sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "core_notifi_created_7f4b88_idx" ON "core_notification" ("created_on" DESC, "id" DESC)',
3535
reverse_sql='DROP INDEX IF EXISTS "core_notifi_created_7f4b88_idx"',
3636
state_operations=[
3737
migrations.AddIndex(
@@ -41,7 +41,7 @@ class Migration(migrations.Migration):
4141
],
4242
),
4343
migrations.RunSQL(
44-
sql='CREATE INDEX CONCURRENTLY "core_notifi_created_4b2233_idx" ON "core_notificationrecipient" ("created_on" DESC, "id" DESC)',
44+
sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "core_notifi_created_4b2233_idx" ON "core_notificationrecipient" ("created_on" DESC, "id" DESC)',
4545
reverse_sql='DROP INDEX IF EXISTS "core_notifi_created_4b2233_idx"',
4646
state_operations=[
4747
migrations.AddIndex(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "bug",
3+
"message": "Make concurrent index migrations idempotent so they can be re-run after a partial failure.",
4+
"issue_origin": "github",
5+
"issue_number": null,
6+
"domain": "core",
7+
"bullet_points": [],
8+
"created_at": "2026-04-20"
9+
}

0 commit comments

Comments
 (0)