Add unique index on entities.extid
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 16 Jan 2015 12:43:32 +0100
changeset 10208 249126034c0e
parent 10207 5ec5d17b5e5b
child 10209 4c64a41c0a1d
Add unique index on entities.extid
misc/migration/3.21.0_Any.py
server/sources/native.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/migration/3.21.0_Any.py	Fri Jan 16 12:43:32 2015 +0100
@@ -0,0 +1,5 @@
+
+helper = repo.system_source.dbhelper
+sql('DROP INDEX entities_extid_idx')
+sql(helper.sql_create_index('entities', 'extid', True))
+commit()
--- a/server/sources/native.py	Fri Jan 16 11:17:53 2015 +0100
+++ b/server/sources/native.py	Fri Jan 16 12:43:32 2015 +0100
@@ -1387,10 +1387,9 @@
   eid INTEGER PRIMARY KEY NOT NULL,
   type VARCHAR(64) NOT NULL,
   asource VARCHAR(128) NOT NULL,
-  extid VARCHAR(256)
+  extid VARCHAR(256) UNIQUE
 );;
 CREATE INDEX entities_type_idx ON entities(type);;
-CREATE INDEX entities_extid_idx ON entities(extid);;
 
 CREATE TABLE transactions (
   tx_uuid CHAR(32) PRIMARY KEY NOT NULL,