Created
February 14, 2015 23:42
-
-
Save MarkusH/bc3cb7b526dc39470cdc to your computer and use it in GitHub Desktop.
Django migration operations with custom schema editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MaterializedViewOperationMixin(object): | |
def get_schema_editor(self, app_label, schema_editor): | |
if app_label in {'app1', 'app2'}: | |
return CustomSchemaEditor() | |
return schema_editor | |
class MaterializedViewCreateModel(MaterializedViewOperationMixin, CreateModel): | |
def database_forwards(self, app_label, schema_editor, from_state, to_state): | |
schema_editor = self.get_schema_editor(app_label, schema_editor) | |
super(MaterializedViewCreateModel, self).database_forwards(self, app_label, schema_editor, from_state, to_state) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment