misc/migration/bootstrapmigration_repository.py
branchstable
changeset 9163 fe4c1c1982e7
parent 8830 7fd6c52ef878
child 9450 af4b93bc38a5
child 9515 b0dd5b57d2d8
equal deleted inserted replaced
9162:bf0a575d8da8 9163:fe4c1c1982e7
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    18 """allways executed before all others in server migration
    18 """allways executed before all others in server migration
    19 
    19 
    20 it should only include low level schema changes
    20 it should only include low level schema changes
    21 """
    21 """
    22 
    22 
       
    23 from cubicweb import ConfigurationError
    23 from cubicweb.server.session import hooks_control
    24 from cubicweb.server.session import hooks_control
    24 from cubicweb.server import schemaserial as ss
    25 from cubicweb.server import schemaserial as ss
    25 
    26 
    26 applcubicwebversion, cubicwebversion = versions_map['cubicweb']
    27 applcubicwebversion, cubicwebversion = versions_map['cubicweb']
    27 
    28 
    35     commit(ask_confirm=False)
    36     commit(ask_confirm=False)
    36 
    37 
    37 if applcubicwebversion < (3, 17, 0) and cubicwebversion >= (3, 17, 0):
    38 if applcubicwebversion < (3, 17, 0) and cubicwebversion >= (3, 17, 0):
    38     try:
    39     try:
    39         add_cube('sioc', update_database=False)
    40         add_cube('sioc', update_database=False)
    40     except ImportError:
    41     except ConfigurationError:
    41         if not confirm('In cubicweb 3.17 sioc views have been moved to the sioc '
    42         if not confirm('In cubicweb 3.17 sioc views have been moved to the sioc '
    42                        'cube, which is not installed.  Continue anyway?'):
    43                        'cube, which is not installed.  Continue anyway?'):
    43             raise
    44             raise
    44     try:
    45     try:
    45         add_cube('embed', update_database=False)
    46         add_cube('embed', update_database=False)
    46     except ImportError:
    47     except ConfigurationError:
    47         if not confirm('In cubicweb 3.17 embedding views have been moved to the embed '
    48         if not confirm('In cubicweb 3.17 embedding views have been moved to the embed '
    48                        'cube, which is not installed.  Continue anyway?'):
    49                        'cube, which is not installed.  Continue anyway?'):
    49             raise
    50             raise
    50     try:
    51     try:
    51         add_cube('geocoding', update_database=False)
    52         add_cube('geocoding', update_database=False)
    52     except ImportError:
    53     except ConfigurationError:
    53         if not confirm('In cubicweb 3.17 geocoding views have been moved to the geocoding '
    54         if not confirm('In cubicweb 3.17 geocoding views have been moved to the geocoding '
    54                        'cube, which is not installed.  Continue anyway?'):
    55                        'cube, which is not installed.  Continue anyway?'):
    55             raise
    56             raise
    56 
    57 
    57 if applcubicwebversion <= (3, 13, 0) and cubicwebversion >= (3, 13, 1):
    58 if applcubicwebversion <= (3, 13, 0) and cubicwebversion >= (3, 13, 1):
    70 if applcubicwebversion <= (3, 14, 0) and cubicwebversion >= (3, 14, 0):
    71 if applcubicwebversion <= (3, 14, 0) and cubicwebversion >= (3, 14, 0):
    71     if 'require_permission' in schema and not 'localperms'in repo.config.cubes():
    72     if 'require_permission' in schema and not 'localperms'in repo.config.cubes():
    72         from cubicweb import ExecutionError
    73         from cubicweb import ExecutionError
    73         try:
    74         try:
    74             add_cube('localperms', update_database=False)
    75             add_cube('localperms', update_database=False)
    75         except ImportError:
    76         except ConfigurationError:
    76             raise ExecutionError('In cubicweb 3.14, CWPermission and related stuff '
    77             raise ExecutionError('In cubicweb 3.14, CWPermission and related stuff '
    77                                  'has been moved to cube localperms. Install it first.')
    78                                  'has been moved to cube localperms. Install it first.')
    78 
    79 
    79 if applcubicwebversion == (3, 6, 0) and cubicwebversion >= (3, 6, 0):
    80 if applcubicwebversion == (3, 6, 0) and cubicwebversion >= (3, 6, 0):
    80     CSTRMAP = dict(rql('Any T, X WHERE X is CWConstraintType, X name T',
    81     CSTRMAP = dict(rql('Any T, X WHERE X is CWConstraintType, X name T',