author | Philippe Pepiot <ph@itsalwaysdns.eu> |
Tue, 31 Mar 2020 19:15:03 +0200 | |
changeset 12957 | 0c973204033a |
parent 12185 | c46f2bf815d2 |
permissions | -rw-r--r-- |
11890
01bfc50e1a47
Ensure in 3.24 migration that entities from LDAP have consistent cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11808
diff
changeset
|
1 |
from base64 import b64decode |
01bfc50e1a47
Ensure in 3.24 migration that entities from LDAP have consistent cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11808
diff
changeset
|
2 |
|
01bfc50e1a47
Ensure in 3.24 migration that entities from LDAP have consistent cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11808
diff
changeset
|
3 |
|
01bfc50e1a47
Ensure in 3.24 migration that entities from LDAP have consistent cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11808
diff
changeset
|
4 |
# before removing extid, ensure it's coherent with cwuri |
01bfc50e1a47
Ensure in 3.24 migration that entities from LDAP have consistent cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11808
diff
changeset
|
5 |
for eid, etype, encoded_extid in sql( |
01bfc50e1a47
Ensure in 3.24 migration that entities from LDAP have consistent cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11808
diff
changeset
|
6 |
"SELECT eid, type, extid FROM entities, cw_CWSource " |
01bfc50e1a47
Ensure in 3.24 migration that entities from LDAP have consistent cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11808
diff
changeset
|
7 |
"WHERE cw_CWSource.cw_name=entities.asource AND cw_CWSource.cw_type='ldapfeed'"): |
01bfc50e1a47
Ensure in 3.24 migration that entities from LDAP have consistent cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11808
diff
changeset
|
8 |
sql('UPDATE cw_{} SET cw_cwuri=%(cwuri)s WHERE cw_eid=%(eid)s'.format(etype), |
01bfc50e1a47
Ensure in 3.24 migration that entities from LDAP have consistent cwuri
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11808
diff
changeset
|
9 |
{'eid': eid, 'cwuri': b64decode(encoded_extid)}) |
11937
7d3ee5a516fa
[migration] Fix crash on 3.24 migration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11890
diff
changeset
|
10 |
|
12185
c46f2bf815d2
[migration] Only drop moved table entities if it does not exists
Yann Voté <yann.vote@logilab.fr>
parents:
11948
diff
changeset
|
11 |
sql('DROP TABLE IF EXISTS moved_entities') |
11937
7d3ee5a516fa
[migration] Fix crash on 3.24 migration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11890
diff
changeset
|
12 |
sql('ALTER TABLE entities DROP COLUMN asource') |
11774
51c160677afe
[repository] Drop the entities.extid column and associated cache
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11773
diff
changeset
|
13 |
sql('ALTER TABLE entities DROP COLUMN extid') |
11776
b49684ddd543
[repository] Drop the index on entities.type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11775
diff
changeset
|
14 |
sql('DROP INDEX entities_type_idx') |
11775
39cf9e55ada8
[source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11774
diff
changeset
|
15 |
|
11808
4a387179fa33
[migration] Drop cw_schema relation first
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11776
diff
changeset
|
16 |
# force cw_schema deletion before CWSourceSchemaConfig to avoid nasty bug |
4a387179fa33
[migration] Drop cw_schema relation first
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11776
diff
changeset
|
17 |
drop_relation_type('cw_schema') |
11775
39cf9e55ada8
[source] Drop source mapping handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11774
diff
changeset
|
18 |
drop_entity_type('CWSourceSchemaConfig') |
11948
73ed9c204de9
[migration] Move pyramid-related migration after "entities" table modifications
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11937
diff
changeset
|
19 |
|
73ed9c204de9
[migration] Move pyramid-related migration after "entities" table modifications
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11937
diff
changeset
|
20 |
# Check the CW versions and add the entity only if needed ? |
73ed9c204de9
[migration] Move pyramid-related migration after "entities" table modifications
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11937
diff
changeset
|
21 |
add_entity_type('CWSession') |
73ed9c204de9
[migration] Move pyramid-related migration after "entities" table modifications
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11937
diff
changeset
|
22 |
rql('DELETE CWProperty X WHERE X pkey "system.version.pyramid"', |
73ed9c204de9
[migration] Move pyramid-related migration after "entities" table modifications
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11937
diff
changeset
|
23 |
ask_confirm=False) |