misc/migration/3.21.0_Any.py
author Julien Cristau <julien.cristau@logilab.fr>
Mon, 18 May 2015 16:44:49 +0200
changeset 10439 45e18b4a7466
parent 10371 88577b10b31e
child 10448 de5be53e2ea8
permissions -rw-r--r--
[devtools] change the way we start/stop postgresql Instead of having the test db handler start a cluster on demand, use the test module's setUp/tearDown callbacks to do it. This allows to have one data directory (and thus cluster) per test module, allowing different test modules to run in parallel, each using its own database cluster whose path is based on the test module.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10208
249126034c0e Add unique index on entities.extid
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     1
249126034c0e Add unique index on entities.extid
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     2
helper = repo.system_source.dbhelper
249126034c0e Add unique index on entities.extid
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     3
sql('DROP INDEX entities_extid_idx')
249126034c0e Add unique index on entities.extid
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
     4
sql(helper.sql_create_index('entities', 'extid', True))
10209
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
     5
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
     6
sql('''
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
     7
CREATE TABLE moved_entities (
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
     8
  eid INTEGER PRIMARY KEY NOT NULL,
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
     9
  extid VARCHAR(256) UNIQUE
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
    10
)
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
    11
''')
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
    12
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
    13
moved_entities = sql('SELECT -eid, extid FROM entities WHERE eid < 0')
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
    14
cu = session.cnxset.cu
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
    15
cu.executemany('INSERT INTO moved_entities (eid, extid) VALUES (%s, %s)',
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
    16
               moved_entities)
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
    17
sql('DELETE FROM entities WHERE eid < 0')
4c64a41c0a1d Use a moved_entities table to record external entities moved to the system source
Julien Cristau <julien.cristau@logilab.fr>
parents: 10208
diff changeset
    18
10208
249126034c0e Add unique index on entities.extid
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff changeset
    19
commit()
10316
4ce8b8437838 [schemas] make CWEType.final default to False (closes #5049201)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 10209
diff changeset
    20
4ce8b8437838 [schemas] make CWEType.final default to False (closes #5049201)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 10209
diff changeset
    21
sync_schema_props_perms('CWEType')
10371
88577b10b31e [schema] add a unique index on cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10316
diff changeset
    22
88577b10b31e [schema] add a unique index on cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 10316
diff changeset
    23
sync_schema_props_perms('cwuri')