[FIX] base: ir.model.data: safer tests for index creation

Complements b99ef3b125.
The index definitions have changed, so we need distinct names
and existence tests to make sure they get properly created/altered
on older databases.
This commit is contained in:
Olivier Dony
2015-10-27 11:06:58 +01:00
parent ea12117f65
commit 76593cd081
+4 -2
View File
@@ -937,9 +937,11 @@ class ir_model_data(osv.osv):
def _auto_init(self, cr, context=None):
super(ir_model_data, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'ir_model_data_module_name_index\'')
cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = 'ir_model_data_module_name_uniq_index'")
if not cr.fetchone():
cr.execute('CREATE UNIQUE INDEX ir_model_data_module_name_uniq_index ON ir_model_data (module, name)')
cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = 'ir_model_data_model_res_id_index'")
if not cr.fetchone():
cr.execute('CREATE UNIQUE INDEX ir_model_data_module_name_index ON ir_model_data (module, name)')
cr.execute('CREATE INDEX ir_model_data_model_res_id_index ON ir_model_data (model, res_id)')
# NEW V8 API