Add id column if missing on table
This commit is contained in:
1 parent
5a507e23e7
commit
9aca50d788
1 file changed
+6
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user