cubicweb/misc/migration/3.24.0_Any.py
author Philippe Pepiot <ph@itsalwaysdns.eu>
Tue, 31 Mar 2020 19:15:03 +0200
changeset 12957 0c973204033a
parent 12185 c46f2bf815d2
permissions -rw-r--r--
[server] prevent returning closed cursor to the database pool In since c8c6ad8 init_repository use repo.internal_cnx() instead of repo.system_source.get_connection() so it use the pool and we should not close cursors from the pool before returning it back. Otherwise we may have "connection already closed" error. This bug only trigger when connection-pool-size = 1. Since we are moving to use a dynamic pooler we need to get this fixed. This does not occur with sqlite since the connection wrapper instantiate new cursor everytime, but this occur with other databases.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)