From edd889348c8aa3fa8d23f79d0f8a6b832a9e07e4 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 6 Mar 2013 16:29:57 +0000 Subject: [PATCH] delete sequence data directly --- pandora/sequence/migrations/0002_optimize1.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandora/sequence/migrations/0002_optimize1.py b/pandora/sequence/migrations/0002_optimize1.py index 426727032..72cb33e1f 100644 --- a/pandora/sequence/migrations/0002_optimize1.py +++ b/pandora/sequence/migrations/0002_optimize1.py @@ -2,12 +2,17 @@ import datetime from south.db import db from south.v2 import SchemaMigration -from django.db import models +from django.db import models, connection, transaction class Migration(SchemaMigration): def forwards(self, orm): + table_name = orm['sequence.Sequence']._meta.db_table + cursor = connection.cursor() + sql = 'DELETE FROM "%s" WHERE 1=1' % table_name + cursor.execute(sql) + transaction.commit_unless_managed() # Removing unique constraint on 'Sequence', fields ['item', 'end', 'mode', 'start'] db.delete_unique('sequence_sequence', ['item_id', 'end', 'mode', 'start']) @@ -31,8 +36,6 @@ class Migration(SchemaMigration): # Adding unique constraint on 'Sequence', fields ['sort', 'start', 'end', 'mode'] db.create_unique('sequence_sequence', ['sort_id', 'start', 'end', 'mode']) - orm['sequence.Sequence'].objects.all().delete() - def backwards(self, orm): # Removing unique constraint on 'Sequence', fields ['sort', 'start', 'end', 'mode'] db.delete_unique('sequence_sequence', ['sort_id', 'start', 'end', 'mode'])