Created
October 23, 2010 19:57
-
-
Save trepca/642623 to your computer and use it in GitHub Desktop.
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 Migration(DataMigration): | |
def forwards(self, orm): | |
for todo in orm.Todo.objects.all(): | |
if todo.all_day or todo.location: | |
obj = orm.Event() | |
obj.all_day = todo.all_day | |
obj.location = todo.location | |
obj.end_date = todo.due_date | |
else: | |
obj = orm.Task() | |
obj.due_date = todo.due_date | |
obj.title = todo.title | |
obj.start_date = todo.start_date | |
obj.due_date = todo.due_date | |
obj.date_created = todo.date_created | |
obj.owner = todo.owner | |
obj.save() | |
if todo.body: | |
note = orm.Note(body=todo.body) | |
note.save() | |
obj.notes.add(note) | |
def backwards(self, orm): | |
"all data is only copied anyway, so no backward code needed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment