forked from 0x2620/pandora
delete sequence data directly
This commit is contained in:
parent
f48f62b6a0
commit
edd889348c
1 changed files with 6 additions and 3 deletions
|
@ -2,12 +2,17 @@
|
||||||
import datetime
|
import datetime
|
||||||
from south.db import db
|
from south.db import db
|
||||||
from south.v2 import SchemaMigration
|
from south.v2 import SchemaMigration
|
||||||
from django.db import models
|
from django.db import models, connection, transaction
|
||||||
|
|
||||||
|
|
||||||
class Migration(SchemaMigration):
|
class Migration(SchemaMigration):
|
||||||
|
|
||||||
def forwards(self, orm):
|
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']
|
# Removing unique constraint on 'Sequence', fields ['item', 'end', 'mode', 'start']
|
||||||
db.delete_unique('sequence_sequence', ['item_id', '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']
|
# Adding unique constraint on 'Sequence', fields ['sort', 'start', 'end', 'mode']
|
||||||
db.create_unique('sequence_sequence', ['sort_id', 'start', 'end', 'mode'])
|
db.create_unique('sequence_sequence', ['sort_id', 'start', 'end', 'mode'])
|
||||||
|
|
||||||
orm['sequence.Sequence'].objects.all().delete()
|
|
||||||
|
|
||||||
def backwards(self, orm):
|
def backwards(self, orm):
|
||||||
# Removing unique constraint on 'Sequence', fields ['sort', 'start', 'end', 'mode']
|
# Removing unique constraint on 'Sequence', fields ['sort', 'start', 'end', 'mode']
|
||||||
db.delete_unique('sequence_sequence', ['sort_id', 'start', 'end', 'mode'])
|
db.delete_unique('sequence_sequence', ['sort_id', 'start', 'end', 'mode'])
|
||||||
|
|
Loading…
Reference in a new issue