From 9aca50d788d722454fafc5bb140feadd92c63eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 5 Mar 2009 14:46:53 +0100 Subject: [PATCH] Add id column if missing on table --- trytond/backend/postgresql/table.py | 6 ++++++ 1 file changed, 6 insertions(+) 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):