4 # Check the CW versions and add the entity only if needed ? |
4 # Check the CW versions and add the entity only if needed ? |
5 add_entity_type('CWSession') |
5 add_entity_type('CWSession') |
6 rql('DELETE CWProperty X WHERE X pkey "system.version.pyramid"', |
6 rql('DELETE CWProperty X WHERE X pkey "system.version.pyramid"', |
7 ask_confirm=False) |
7 ask_confirm=False) |
8 |
8 |
9 sql('DROP TABLE moved_entities') |
|
10 sql('ALTER TABLE entities DROP COLUMN asource') |
|
11 # before removing extid, ensure it's coherent with cwuri |
9 # before removing extid, ensure it's coherent with cwuri |
12 for eid, etype, encoded_extid in sql( |
10 for eid, etype, encoded_extid in sql( |
13 "SELECT eid, type, extid FROM entities, cw_CWSource " |
11 "SELECT eid, type, extid FROM entities, cw_CWSource " |
14 "WHERE cw_CWSource.cw_name=entities.asource AND cw_CWSource.cw_type='ldapfeed'"): |
12 "WHERE cw_CWSource.cw_name=entities.asource AND cw_CWSource.cw_type='ldapfeed'"): |
15 sql('UPDATE cw_{} SET cw_cwuri=%(cwuri)s WHERE cw_eid=%(eid)s'.format(etype), |
13 sql('UPDATE cw_{} SET cw_cwuri=%(cwuri)s WHERE cw_eid=%(eid)s'.format(etype), |
16 {'eid': eid, 'cwuri': b64decode(encoded_extid)}) |
14 {'eid': eid, 'cwuri': b64decode(encoded_extid)}) |
|
15 |
|
16 sql('DROP TABLE moved_entities') |
|
17 sql('ALTER TABLE entities DROP COLUMN asource') |
17 sql('ALTER TABLE entities DROP COLUMN extid') |
18 sql('ALTER TABLE entities DROP COLUMN extid') |
18 sql('DROP INDEX entities_type_idx') |
19 sql('DROP INDEX entities_type_idx') |
19 |
20 |
20 # force cw_schema deletion before CWSourceSchemaConfig to avoid nasty bug |
21 # force cw_schema deletion before CWSourceSchemaConfig to avoid nasty bug |
21 drop_relation_type('cw_schema') |
22 drop_relation_type('cw_schema') |