diff --git a/trytond/backend/postgresql/table.py b/trytond/backend/postgresql/table.py index 162ec98714..527947a1ed 100644 --- a/trytond/backend/postgresql/table.py +++ b/trytond/backend/postgresql/table.py @@ -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):