misc/migration/bootstrapmigration_repository.py
changeset 2462 9e670072884d
parent 2275 bc0bed0616a3
child 2463 5200c0f7d2d5
equal deleted inserted replaced
2461:1f38b65cbd20 2462:9e670072884d
     9 """
     9 """
    10 
    10 
    11 applcubicwebversion, cubicwebversion = versions_map['cubicweb']
    11 applcubicwebversion, cubicwebversion = versions_map['cubicweb']
    12 
    12 
    13 if applcubicwebversion < (3, 2, 2) and cubicwebversion >= (3, 2, 1):
    13 if applcubicwebversion < (3, 2, 2) and cubicwebversion >= (3, 2, 1):
    14    from base64 import b64encode
    14     from base64 import b64encode
    15    for table in ('entities', 'deleted_entities'):
    15     for table in ('entities', 'deleted_entities'):
    16       for eid, extid in sql('SELECT eid, extid FROM %s WHERE extid is NOT NULL'
    16         for eid, extid in sql('SELECT eid, extid FROM %s WHERE extid is NOT NULL'
    17                             % table, ask_confirm=False):
    17                               % table, ask_confirm=False):
    18          sql('UPDATE %s SET extid=%%(extid)s WHERE eid=%%(eid)s' % table,
    18             sql('UPDATE %s SET extid=%%(extid)s WHERE eid=%%(eid)s' % table,
    19              {'extid': b64encode(extid), 'eid': eid}, ask_confirm=False)
    19                 {'extid': b64encode(extid), 'eid': eid}, ask_confirm=False)
    20    checkpoint()
    20     checkpoint()
    21 
    21 
    22 if applcubicwebversion < (3, 2, 0) and cubicwebversion >= (3, 2, 0):
    22 if applcubicwebversion < (3, 2, 0) and cubicwebversion >= (3, 2, 0):
    23    add_cube('card', update_database=False)
    23     add_cube('card', update_database=False)
    24 
    24 
    25 if applcubicwebversion < (2, 47, 0) and cubicwebversion >= (2, 47, 0):
    25 if applcubicwebversion < (2, 47, 0) and cubicwebversion >= (2, 47, 0):
    26     from cubicweb.server import schemaserial
    26      from cubicweb.server import schemaserial
    27     schemaserial.HAS_FULLTEXT_CONTAINER = False
    27      schemaserial.HAS_FULLTEXT_CONTAINER = False
    28     session.set_shared_data('do-not-insert-is_instance_of', True)
    28      session.set_shared_data('do-not-insert-is_instance_of', True)
    29     add_attribute('CWRType', 'fulltext_container')
    29      add_attribute('CWRType', 'fulltext_container')
    30     schemaserial.HAS_FULLTEXT_CONTAINER = True
    30      schemaserial.HAS_FULLTEXT_CONTAINER = True
    31 
    31 
    32 
    32 
    33 
    33 
    34 if applcubicwebversion < (2, 50, 0) and cubicwebversion >= (2, 50, 0):
    34 if applcubicwebversion < (2, 50, 0) and cubicwebversion >= (2, 50, 0):
    35     session.set_shared_data('do-not-insert-is_instance_of', True)
    35      session.set_shared_data('do-not-insert-is_instance_of', True)
    36     add_relation_type('is_instance_of')
    36      add_relation_type('is_instance_of')
    37     # fill the relation using an efficient sql query instead of using rql
    37      # fill the relation using an efficient sql query instead of using rql
    38     sql('INSERT INTO is_instance_of_relation '
    38      sql('INSERT INTO is_instance_of_relation '
    39         '  SELECT * from is_relation')
    39          '  SELECT * from is_relation')
    40     checkpoint()
    40      checkpoint()
    41     session.set_shared_data('do-not-insert-is_instance_of', False)
    41      session.set_shared_data('do-not-insert-is_instance_of', False)
    42 
    42 
    43 if applcubicwebversion < (2, 42, 0) and cubicwebversion >= (2, 42, 0):
    43 if applcubicwebversion < (2, 42, 0) and cubicwebversion >= (2, 42, 0):
    44     sql('ALTER TABLE entities ADD COLUMN mtime TIMESTAMP')
    44      sql('ALTER TABLE entities ADD COLUMN mtime TIMESTAMP')
    45     sql('UPDATE entities SET mtime=CURRENT_TIMESTAMP')
    45      sql('UPDATE entities SET mtime=CURRENT_TIMESTAMP')
    46     sql('CREATE INDEX entities_mtime_idx ON entities(mtime)')
    46      sql('CREATE INDEX entities_mtime_idx ON entities(mtime)')
    47     sql('''CREATE TABLE deleted_entities (
    47      sql('''CREATE TABLE deleted_entities (
    48   eid INTEGER PRIMARY KEY NOT NULL,
    48   eid INTEGER PRIMARY KEY NOT NULL,
    49   type VARCHAR(64) NOT NULL,
    49   type VARCHAR(64) NOT NULL,
    50   source VARCHAR(64) NOT NULL,
    50   source VARCHAR(64) NOT NULL,
    51   dtime TIMESTAMP NOT NULL,
    51   dtime TIMESTAMP NOT NULL,
    52   extid VARCHAR(256)
    52   extid VARCHAR(256)
    53 )''')
    53 )''')
    54     sql('CREATE INDEX deleted_entities_type_idx ON deleted_entities(type)')
    54      sql('CREATE INDEX deleted_entities_type_idx ON deleted_entities(type)')
    55     sql('CREATE INDEX deleted_entities_dtime_idx ON deleted_entities(dtime)')
    55      sql('CREATE INDEX deleted_entities_dtime_idx ON deleted_entities(dtime)')
    56     sql('CREATE INDEX deleted_entities_extid_idx ON deleted_entities(extid)')
    56      sql('CREATE INDEX deleted_entities_extid_idx ON deleted_entities(extid)')
    57     checkpoint()
    57      checkpoint()
    58