2 from django.db import connection
3 from south.db import generic
5 class DatabaseOperations(generic.DatabaseOperations):
8 PsycoPG2 implementation of database operations.
11 def rename_column(self, table_name, old, new):
14 qn = connection.ops.quote_name
15 params = (qn(table_name), qn(old), qn(new))
16 self.execute('ALTER TABLE %s RENAME COLUMN %s TO %s;' % params)
18 def rename_table(self, old_table_name, table_name):
19 # First, rename the table
20 generic.DatabaseOperations.rename_table(self, old_table_name, table_name)
21 # Then, try renaming the ID sequence
22 # (if you're using other AutoFields... your problem, unfortunately)
23 self.commit_transaction()
24 self.start_transaction()
26 generic.DatabaseOperations.rename_table(self, old_table_name+"_id_seq", table_name+"_id_seq")
28 print " ~ No such sequence (ignoring error)"
29 self.rollback_transaction()
31 self.commit_transaction()
32 self.start_transaction()