doc/book/en/B0040-migration.en.txt
changeset 1195 79c1abc64304
parent 1168 ebf7328c251e
child 1440 4fc48f2a1748
equal deleted inserted replaced
1194:e224f064a268 1195:79c1abc64304
    42 
    42 
    43   * `Any`, applies only to the RQL server and updates data in the database
    43   * `Any`, applies only to the RQL server and updates data in the database
    44     (schema and data migration for example).
    44     (schema and data migration for example).
    45 
    45 
    46 Again in the directory `migration`, the file `depends.map` allows to indicate
    46 Again in the directory `migration`, the file `depends.map` allows to indicate
    47 that to migrate to a particular model version, you always have to first migrate
    47 that for the migration to a particular model version, you always have to first 
    48 to a particular `CubicWeb` version. This file can contain comments (lines
    48 migrate to a particular `CubicWeb` version. This file can contain comments (lines
    49 starting by `#`) and a dependancy is listed as follows: ::
    49 starting by `#`) and a dependancy is listed as follows: ::
    50   
    50   
    51   <model version n° X.Y.Z> : <cubicweb version n° X.Y.Z>
    51   <model version n° X.Y.Z> : <cubicweb version n° X.Y.Z>
    52 
    52 
    53 For example: ::
    53 For example: ::
    58   0.15.0: 2.28.0
    58   0.15.0: 2.28.0
    59 
    59 
    60 Base context
    60 Base context
    61 ------------
    61 ------------
    62 
    62 
    63 The following identifiers are pre-defined in the migration scripts:
    63 The following identifiers are pre-defined in migration scripts:
    64 
    64 
    65 * `config`, instance configuration
    65 * `config`, instance configuration
    66 
    66 
    67 * `interactive_mode`, boolean indicating that the script is executed in
    67 * `interactive_mode`, boolean indicating that the script is executed in
    68   an intercative mode or not 
    68   an interactive mode or not 
    69 
    69 
    70 * `appltemplversion`, application model version of the instance
    70 * `appltemplversion`, application model version of the instance
    71 
    71 
    72 * `templversion`, installed application model version
    72 * `templversion`, installed application model version
    73 
    73 
    74 * `cubicwebversion`, installed cubicweb version
    74 * `cubicwebversion`, installed cubicweb version
    75 
    75 
    76 * `confirm(question)`, function interrogating the user and returning true
    76 * `confirm(question)`, function asking the user and returning true
    77   if the user answers yes, false otherwise (always returns true in
    77   if the user answers yes, false otherwise (always returns true in
    78   non-interactive mode)
    78   non-interactive mode)
    79 
    79 
    80 * the function `_`, it is equivalent to `unicode` allowing to flag the strings
    80 * the function `_`, it is equivalent to `unicode` allowing to flag the strings
    81   to internationalize in the migration scripts.
    81   to internationalize in the migration scripts.
    96 * `repo`, repository object
    96 * `repo`, repository object
    97 
    97 
    98                         
    98                         
    99 Schema migration
    99 Schema migration
   100 ----------------
   100 ----------------
   101 The following functions for schema migration are available in the `repository`
   101 The following functions for schema migration are available in `repository`
   102 scripts:
   102 scripts:
   103 
   103 
   104 * `add_attribute(etype, attrname, attrtype=None, commit=True)`, adds a new
   104 * `add_attribute(etype, attrname, attrtype=None, commit=True)`, adds a new
   105   attribute to an existing entity type. If the attribute type is not specified, 
   105   attribute to an existing entity type. If the attribute type is not specified, 
   106   then it is extracted from the updated schema.
   106   then it is extracted from the updated schema.
   146 * `synchronize_schema(commit=True)`, synchronizes the persisting schema with the
   146 * `synchronize_schema(commit=True)`, synchronizes the persisting schema with the
   147   updated schema (but without adding or removing new entity types, relations types 
   147   updated schema (but without adding or removing new entity types, relations types 
   148   or even relations definitions).
   148   or even relations definitions).
   149         
   149         
   150 * `change_relation_props(subjtype, rtype, objtype, commit=True, **kwargs)`, changes
   150 * `change_relation_props(subjtype, rtype, objtype, commit=True, **kwargs)`, changes
   151   properties of a relation definition by using the nammed parameters of the properties
   151   properties of a relation definition by using the named parameters of the properties
   152   to change.
   152   to change.
   153 
   153 
   154 * `set_widget(etype, rtype, widget, commit=True)`, changes the widget used for the
   154 * `set_widget(etype, rtype, widget, commit=True)`, changes the widget used for the
   155   relation <rtype> of entity type <etype>.
   155   relation <rtype> of entity type <etype>.
   156 
   156 
   157 * `set_size_constraint(etype, rtype, size, commit=True)`, changes the size constraints
   157 * `set_size_constraint(etype, rtype, size, commit=True)`, changes the size constraints
   158   for the relation <rtype> of entity type <etype>.
   158   for the relation <rtype> of entity type <etype>.
   159 
   159 
   160 Data migration
   160 Data migration
   161 --------------
   161 --------------
   162 The following functions for data migration are available in the `repository` scripts:
   162 The following functions for data migration are available in `repository` scripts:
   163 
   163 
   164 * `rql(rql, kwargs=None, cachekey=None, ask_confirm=True)`, executes an arbitrary RQL
   164 * `rql(rql, kwargs=None, cachekey=None, ask_confirm=True)`, executes an arbitrary RQL
   165   query, either to interrogate or update. A result set object is returned.  
   165   query, either to interrogate or update. A result set object is returned.  
   166 
   166 
   167 * `add_entity(etype, *args, **kwargs)`, adds a nes entity type of the given
   167 * `add_entity(etype, *args, **kwargs)`, adds a nes entity type of the given
   168   type. The attributes and relations values are specified using the nammed and
   168   type. The attribute and relation values are specified using the named and
   169   positionned parameters.
   169   positionned parameters.
   170 
   170 
   171 Workflow creation
   171 Workflow creation
   172 -----------------
   172 -----------------
   173 
   173 
   174 The following functions for workflow creation are available in the `repository`
   174 The following functions for workflow creation are available in `repository`
   175 scripts:
   175 scripts:
   176 
   176 
   177 * `add_state(name, stateof, initial=False, commit=False, **kwargs)`, adds a new state
   177 * `add_state(name, stateof, initial=False, commit=False, **kwargs)`, adds a new state
   178   in the workflow.
   178   in the workflow.
   179     
   179     
   183 You can find more details about workflows in the chapter :ref:`Workflow` .
   183 You can find more details about workflows in the chapter :ref:`Workflow` .
   184 
   184 
   185 Configuration migration
   185 Configuration migration
   186 -----------------------
   186 -----------------------
   187 
   187 
   188 The following functions for configuration migration are available in all the
   188 The following functions for configuration migration are available in all 
   189 scripts:
   189 scripts:
   190 
   190 
   191 * `option_renamed(oldname, newname)`, indicates that an option has been renammed
   191 * `option_renamed(oldname, newname)`, indicates that an option has been renamed
   192 
   192 
   193 * `option_group_change(option, oldgroup, newgroup)`, indicates that an option does not
   193 * `option_group_change(option, oldgroup, newgroup)`, indicates that an option does not
   194   belong anymore to the same group.
   194   belong anymore to the same group.
   195 
   195 
   196 * `option_added(oldname, newname)`, indicates that an option has been added.
   196 * `option_added(oldname, newname)`, indicates that an option has been added.
   200 
   200 
   201 Others migration functions
   201 Others migration functions
   202 --------------------------
   202 --------------------------
   203 Those functions are only used for low level operations that could not be 
   203 Those functions are only used for low level operations that could not be 
   204 accomplished otherwise or to repair damaged databases during interactive 
   204 accomplished otherwise or to repair damaged databases during interactive 
   205 session. They are available in the `repository` scripts:
   205 session. They are available in `repository` scripts:
   206 
   206 
   207 * `sqlexec(sql, args=None, ask_confirm=True)`, executes an arbitrary SQL query
   207 * `sqlexec(sql, args=None, ask_confirm=True)`, executes an arbitrary SQL query
   208 * `add_entity_type_table(etype, commit=True)`
   208 * `add_entity_type_table(etype, commit=True)`
   209 * `add_relation_type_table(rtype, commit=True)`
   209 * `add_relation_type_table(rtype, commit=True)`
   210 * `uninline_relation(rtype, commit=True)`
   210 * `uninline_relation(rtype, commit=True)`