|
1 from base64 import b64decode |
|
2 |
|
3 |
1 # Check the CW versions and add the entity only if needed ? |
4 # Check the CW versions and add the entity only if needed ? |
2 add_entity_type('CWSession') |
5 add_entity_type('CWSession') |
3 rql('DELETE CWProperty X WHERE X pkey "system.version.pyramid"', |
6 rql('DELETE CWProperty X WHERE X pkey "system.version.pyramid"', |
4 ask_confirm=False) |
7 ask_confirm=False) |
5 |
8 |
6 sql('DROP TABLE moved_entities') |
9 sql('DROP TABLE moved_entities') |
7 sql('ALTER TABLE entities DROP COLUMN asource') |
10 sql('ALTER TABLE entities DROP COLUMN asource') |
|
11 # before removing extid, ensure it's coherent with cwuri |
|
12 for eid, etype, encoded_extid in sql( |
|
13 "SELECT eid, type, extid FROM entities, cw_CWSource " |
|
14 "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), |
|
16 {'eid': eid, 'cwuri': b64decode(encoded_extid)}) |
8 sql('ALTER TABLE entities DROP COLUMN extid') |
17 sql('ALTER TABLE entities DROP COLUMN extid') |
9 sql('DROP INDEX entities_type_idx') |
18 sql('DROP INDEX entities_type_idx') |
10 |
19 |
11 # force cw_schema deletion before CWSourceSchemaConfig to avoid nasty bug |
20 # force cw_schema deletion before CWSourceSchemaConfig to avoid nasty bug |
12 drop_relation_type('cw_schema') |
21 drop_relation_type('cw_schema') |