cubicweb/misc/migration/bootstrapmigration_repository.py
changeset 11773 054a947b5415
parent 11767 432f87a63057
child 11774 51c160677afe
equal deleted inserted replaced
11772:54fa73a2f931 11773:054a947b5415
    51 
    51 
    52     cursor.execute(dbh.sql_drop_sequence('entities_id_seq'))
    52     cursor.execute(dbh.sql_drop_sequence('entities_id_seq'))
    53     cursor.execute(dbh.sql_create_numrange('entities_id_seq'))
    53     cursor.execute(dbh.sql_create_numrange('entities_id_seq'))
    54     cursor.execute(dbh.sql_restart_numrange('entities_id_seq', initial_value=lasteid))
    54     cursor.execute(dbh.sql_restart_numrange('entities_id_seq', initial_value=lasteid))
    55     session.commit()
    55     session.commit()
    56 
       
    57 if applcubicwebversion <= (3, 13, 0) and cubicwebversion >= (3, 13, 1):
       
    58     sql('ALTER TABLE entities ADD asource VARCHAR(64)')
       
    59     sql('UPDATE entities SET asource=cw_name  '
       
    60         'FROM cw_CWSource, cw_source_relation '
       
    61         'WHERE entities.eid=cw_source_relation.eid_from AND cw_source_relation.eid_to=cw_CWSource.cw_eid')
       
    62     commit()
       
    63 
       
    64 if applcubicwebversion <= (3, 14, 4) and cubicwebversion >= (3, 14, 4):
       
    65     from cubicweb.server import schema2sql as y2sql
       
    66     dbhelper = repo.system_source.dbhelper
       
    67     rdefdef = schema['CWSource'].rdef('name')
       
    68     attrtype = y2sql.type_from_constraints(dbhelper, rdefdef.object, rdefdef.constraints).split()[0]
       
    69     cursor = session.cnxset.cu
       
    70     sql('UPDATE entities SET asource = source WHERE asource is NULL')
       
    71     dbhelper.change_col_type(cursor, 'entities', 'asource', attrtype, False)
       
    72     dbhelper.change_col_type(cursor, 'entities', 'source', attrtype, False)
       
    73 
    56 
    74 if applcubicwebversion < (3, 19, 0) and cubicwebversion >= (3, 19, 0):
    57 if applcubicwebversion < (3, 19, 0) and cubicwebversion >= (3, 19, 0):
    75     try: 
    58     try: 
    76         # need explicit drop of the indexes on some database systems (sqlserver)
    59         # need explicit drop of the indexes on some database systems (sqlserver)
    77         sql(repo.system_source.dbhelper.sql_drop_index('entities', 'mtime'))
    60         sql(repo.system_source.dbhelper.sql_drop_index('entities', 'mtime'))