diff options
author | Matthew Schinckel <matt@schinckel.net> | 2014-06-11 22:30:52 +0930 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2014-06-16 12:28:52 -0400 |
commit | bb39037fcbe07a4c4060764533b5c03a4018bf81 (patch) | |
tree | 3a0d501f187c548d6a4be2af8ab1765d4686c944 /tests/custom_migration_operations | |
parent | 37a8f5aeedcfc5b4605960e5dc3d989456ce88b9 (diff) | |
download | django-bb39037fcbe07a4c4060764533b5c03a4018bf81.tar.gz |
Fixed #22788 -- Ensured custom migration operations can be written.
This inspects the migration operation, and if it is not in the
django.db.migrations module, it adds the relevant imports to the
migration writer and uses the correct class name.
Diffstat (limited to 'tests/custom_migration_operations')
-rw-r--r-- | tests/custom_migration_operations/__init__.py | 0 | ||||
-rw-r--r-- | tests/custom_migration_operations/more_operations.py | 22 | ||||
-rw-r--r-- | tests/custom_migration_operations/operations.py | 26 |
3 files changed, 48 insertions, 0 deletions
diff --git a/tests/custom_migration_operations/__init__.py b/tests/custom_migration_operations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/custom_migration_operations/__init__.py diff --git a/tests/custom_migration_operations/more_operations.py b/tests/custom_migration_operations/more_operations.py new file mode 100644 index 0000000000..6fe3d1cf93 --- /dev/null +++ b/tests/custom_migration_operations/more_operations.py @@ -0,0 +1,22 @@ +from django.db.migrations.operations.base import Operation + + +class TestOperation(Operation): + def __init__(self): + pass + + @property + def reversible(self): + return True + + def state_forwards(self, app_label, state): + pass + + def database_forwards(self, app_label, schema_editor, from_state, to_state): + pass + + def state_backwards(self, app_label, state): + pass + + def database_backwards(self, app_label, schema_editor, from_state, to_state): + pass diff --git a/tests/custom_migration_operations/operations.py b/tests/custom_migration_operations/operations.py new file mode 100644 index 0000000000..fc084f8412 --- /dev/null +++ b/tests/custom_migration_operations/operations.py @@ -0,0 +1,26 @@ +from django.db.migrations.operations.base import Operation + + +class TestOperation(Operation): + def __init__(self): + pass + + @property + def reversible(self): + return True + + def state_forwards(self, app_label, state): + pass + + def database_forwards(self, app_label, schema_editor, from_state, to_state): + pass + + def state_backwards(self, app_label, state): + pass + + def database_backwards(self, app_label, schema_editor, from_state, to_state): + pass + + +class CreateModel(TestOperation): + pass |