5
5
from django .db .models import Field , Model
6
6
from django .db .models .base import ModelBase
7
7
from django_zero_downtime_migrations .backends .postgres .schema import (
8
- DatabaseSchemaEditorMixin ,
8
+ DatabaseSchemaEditorMixin as ZeroDowntimeMixin ,
9
+ )
10
+ from django_zero_downtime_migrations .backends .postgres .schema import (
9
11
Unsafe ,
10
12
UnsafeOperationException ,
11
13
)
14
+ from pgtrigger .migrations import DatabaseSchemaEditorMixin as PgTriggerMixin
12
15
13
16
unsafe_mapping = {
14
17
Unsafe .ADD_COLUMN_NOT_NULL : (
@@ -59,7 +62,7 @@ def inner(self, *args, **kwargs):
59
62
return inner
60
63
61
64
62
- class MakeBtreeGistSchemaEditor (PostgresDatabaseSchemaEditor ):
65
+ class MakeBtreeGistSchemaEditor (PgTriggerMixin , PostgresDatabaseSchemaEditor ):
63
66
"""workaround for https://code.djangoproject.com/ticket/36374"""
64
67
65
68
def create_model (self , model : type [Model ]) -> None :
@@ -68,7 +71,9 @@ def create_model(self, model: type[Model]) -> None:
68
71
super ().create_model (model )
69
72
70
73
71
- class SafePostgresDatabaseSchemaEditor (DatabaseSchemaEditorMixin , PostgresDatabaseSchemaEditor ):
74
+ class SafePostgresDatabaseSchemaEditor (
75
+ PgTriggerMixin , ZeroDowntimeMixin , PostgresDatabaseSchemaEditor
76
+ ):
72
77
add_field = translate_unsafeoperation_exception (PostgresDatabaseSchemaEditor .add_field )
73
78
alter_field = translate_unsafeoperation_exception (PostgresDatabaseSchemaEditor .alter_field )
74
79
alter_db_tablespace = translate_unsafeoperation_exception (
@@ -94,7 +99,7 @@ def delete_model(self, model, is_safe=False):
94
99
f"Deleting the { model .__name__ } model is unsafe.\n "
95
100
"More info here: https://develop.sentry.dev/database-migrations/#deleting-tables"
96
101
)
97
- super (DatabaseSchemaEditorMixin , self ).delete_model (model )
102
+ super (ZeroDowntimeMixin , self ).delete_model (model )
98
103
99
104
def remove_field (self , model , field , is_safe = False ):
100
105
"""
@@ -105,7 +110,7 @@ def remove_field(self, model, field, is_safe=False):
105
110
f"Removing the { model .__name__ } .{ field .name } field is unsafe.\n "
106
111
"More info here: https://develop.sentry.dev/database-migrations/#deleting-columns"
107
112
)
108
- super (DatabaseSchemaEditorMixin , self ).remove_field (model , field )
113
+ super (ZeroDowntimeMixin , self ).remove_field (model , field )
109
114
110
115
111
116
class DatabaseSchemaEditorProxy :
0 commit comments