Added handling of didaskalia in kwestia.
[wolnelektury.git] / apps / south / db / postgresql_psycopg2.py
1
2 from django.db import connection
3 from south.db import generic
4
5 class DatabaseOperations(generic.DatabaseOperations):
6
7     """
8     PsycoPG2 implementation of database operations.
9     """
10
11     def rename_column(self, table_name, old, new):
12         if old == new:
13             return []
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)
17     
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()
25         try:
26             generic.DatabaseOperations.rename_table(self, old_table_name+"_id_seq", table_name+"_id_seq")
27         except:
28             print "   ~ No such sequence (ignoring error)"
29             self.rollback_transaction()
30         else:
31             self.commit_transaction()
32         self.start_transaction()