Add id column if missing on table

This commit is contained in:
Cédric Krier committed 2009-03-05 14:46:53 +01:00
1 parent 5a507e23e7
commit 9aca50d788
1 file changed
+6
+6
View File
@@ -28,6 +28,12 @@ class TableHandler(TableHandlerInterface):
self.cursor.execute('CREATE TABLE "%s" ' \
'(id INTEGER)' % self.table_name)
self._update_definitions()
if 'id' not in self._columns:
self.cursor.execute('ALTER TABLE "%s" ' \
'ADD COLUMN id SERIAL NOT NULL' % self.table_name)
self.cursor.execute('ALTER TABLE "%s" ' \
'ADD PRIMARY KEY(id)' % self.table_name)
self._update_definitions()
@staticmethod
def table_exist(cursor, table_name):