prevent creating a transaction when updating all tables

This commit is contained in:
Bram Wiepjes committed 2021-03-16 18:15:51 +01:00
1 parent 4ab8b3eeba
commit 5affc3bfa3
1 file changed
+5
@@ -9,6 +9,10 @@ def forward(apps, schema_editor):
connection = connections[settings.USER_TABLE_DATABASE]
with connection.schema_editor() as tables_schema_editor:
# We need to stop the transaction because we might need to lock a lot of tables
# which could result in an out of memory exception.
tables_schema_editor.atomic.__exit__(None, None, None)
for field in DateField.objects.all():
table_name = f'database_table_{field.table.id}'
field_name = f'field_{field.id}'
@@ -20,6 +24,7 @@ def forward(apps, schema_editor):
)
class Migration(migrations.Migration):
dependencies = [