1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
from django.db.migrations.operations.models import DeleteModel
class PostgresDeleteMaterializedViewModel(DeleteModel):
"""Deletes the specified materialized view model."""
def database_forwards(self, app_label, schema_editor, from_state, to_state):
"""Apply this migration operation forwards."""
model = from_state.apps.get_model(app_label, self.name)
if self.allow_migrate_model(schema_editor.connection.alias, model):
schema_editor.delete_materialized_view_model(model)
def database_backwards(
self, app_label, schema_editor, from_state, to_state
):
"""Apply this migration operation backwards."""
model = to_state.apps.get_model(app_label, self.name)
if self.allow_migrate_model(schema_editor.connection.alias, model):
schema_editor.delete_materialized_view_model(model)
def describe(self):
"""Gets a human readable text describing this migration."""
description = super().describe()
description = description.replace("model", "materialized view model")
return description
|