diff -r cd9cc0153835 -r 1632e01a58a9 doc/book/en/B120-migration.en.txt --- a/doc/book/en/B120-migration.en.txt Mon Dec 08 17:33:58 2008 -0800 +++ b/doc/book/en/B120-migration.en.txt Tue Dec 09 11:05:59 2008 -0800 @@ -4,215 +4,207 @@ Migration ========= -Une des idées de base d'Erudi est la création incrémentale d'application, et -pour cela de nombreuses actions sont fournies afin de facilement faire évoluer -une application et tout particulièrement le modèle de données manipulé sans -perdre les données des instances existantes. +One of the main concept in `CubicWeb` is to create incremental applications +and for this purpose multiple actions are provided to facilitate the improvement +of an application and in particular changes applied to the data model +without loosing existing data. -La version courante d'un modèle d'application est données dans le fichier -`__pkginfo__.py` sous forme d'un tuple de 3 entiers. - +The current version of an application model is provided in the file +`__pkginfo__.py` as a tuple of 3 integers. -Gestion des scripts de migrations ---------------------------------- -Les scripts des migrations doivent être placés dans le répertoire `migration` de -l'application, et nommé de la manière suivante : +Migration scripts management +---------------------------- + +Migration scripts needs to be located in the directory `migration` of your +application and nammed accordingly: :: - [_]_.py + [_]_.py -dans lequel : +in which : -* X.Y.Z correspond au n° de version du modèle vers lequel le script permet de - migrer, +* X.Y.Z is the model version number to which the script enable to migrate -* le *mode* (entre le dernier "_" et l'extension ".py") indique à quelle partie - de l'application (serveur RQL, serveur web) le script s'applique en cas - d'installation distribuée. Il peut valoir : +* *mode* (between the last "_" and the extension ".py") indicates which part + of the application (RQL server, web server) the script applies to in case + of distributed installation. Its value could be : - * `common`, s'applique aussi bien sur le serveur RQL que sur le serveur web, - et met à jour des fichiers sur le disque (migration de fichier de - configuration par exemple). + * `common`, applies to the RQL server as well as the web server and updates + files on the hard drive (configuration files migration by example). + + * `web`, applies only to the web server and updates files on the hard drive - * `web`, s'applique uniquement sur le serveur web, et met à jour des fichiers - sur le disque + * `repository`, applies only to the RQL server and updates files on the + hard drive - * `repository`, s'applique uniquement sur le serveur RQL, et met à jour des - fichiers sur le disque - - * `Any`, s'applique uniquement sur le serveur RQL, et met à jour des - données en base (migrations de schéma et de données par ex.) - + * `Any`, applies only to the RQL server and updates data in the database + (schema and data migration by example) -Toujours dans le répertoire `migration`, le fichier spécial `depends.map` permet -d'indiquer que pour migrer vers une version spécifique du modèle, il faut tout -d'abord avoir migrer vers une version données de erudi. Ce fichier peut contenir -des commentaires (lignes commençant par un "#"), et une dépendance est notée sur -une ligne de la manière suivante : :: +Again in the directory `migration`, the file `depends.map` allows to indicate +that to migrate to a particular model version, you always have to first migrate +to a particular `CubicWeb` version. This file can contains comments (lines +starting by `#`) and a dependancy is listed as follows: :: + + : - : - -Par exemple :: +By example: :: 0.12.0: 2.26.0 0.13.0: 2.27.0 # 0.14 works with 2.27 <= erudi <= 2.28 at least 0.15.0: 2.28.0 +Base context +------------ -Contexte de base ----------------- -Les identifiants suivants sont préféfinis dans les scripts de migration : +The following identifiers are pre-defined in the migration scripts: -* `config`, configuration de l'instance +* `config`, instance configuration -* `interactive_mode`, booléen indiquant si le script est éxécuté en mode - interactif ou non +* `interactive_mode`, boolean indicating that the script is executed in + an intercative mode or not -* `appltemplversion`, version du modèle d'application de l'instance +* `appltemplversion`, application model version of the instance -* `applerudiversion`, version erudi de l'instance +* `applerudiversion`, cubicweb instance version -* `templversion`, version du modéle d'application installée +* `templversion`, installed application model version -* `erudiversion`, version erudi installée +* `erudiversion`, installed cubicweb version -* `confirm(question)`, fonction posant une question et retournant vrai si - l'utilisateur a répondu oui, faux sinon (retourne toujours vrai en mode non - interactif) +* `confirm(question)`, function interrogating the user and returning true + if the user answers yes, false otherwise (always returns true when in a + non-interactive mode) -* `_`, fonction équivalente à `unicode` permettant de marquer des chaines à - internationaliser dans les scripts de migration +* `_`, function fonction equivalent to `unicode` allowing to flag the strings + to internationalize in the migration scripts -Dans les scripts "repository", les identifiants suivant sont également définis : +In the `repository` scripts, the following identifiers are also defined: -* `checkpoint`, demande confirmant et effectue un "commit" au point d'appel +* `checkpoint`, request confirming and executing a "commit" at checking point -* `repo_schema`, schéma persistent de l'instance (i.e. schéma de l'instance en - cours de migration) +* `repo_schema`, instance persisting schema (e.g. instance schema of the + current migration) -* `newschema`, schéma installé sur le système de fichier (i.e. schéma de la - version à jour du modèle et de erudi) +* `newschema`, installed schema on the file system (e.g. schema of + the updated model and erudi) -* `sqlcursor`, un curseur SQL pour les très rares cas où il est réellement - nécessaire ou avantageux de passer par du sql +* `sqlcursor`, SQL cursor for very rare cases where it is really + necessary or beneficial to go through the sql -* `repo`, l'objet repository +* `repo`, repository object -Migration de schéma -------------------- -Les fonctions de migration de schéma suivantes sont disponibles dans les scripts -"repository" : +Schema migration +---------------- +The following functions for schema migration are available in the `repository` +scripts: -* `add_attribute(etype, attrname, attrtype=None, commit=True)`, ajoute un - nouvel attribut à un type d'entité existante. Si le type de celui-ci n'est pas - spécifié il est extrait du schéma à jour. +* `add_attribute(etype, attrname, attrtype=None, commit=True)`, adds a new + attribute to an existing entity type. If the attribute type is not specified, + then it is extracted from the updated schema. -* `drop_attribute(etype, attrname, commit=True)`, supprime un - attribut à un type d'entité existante. +* `drop_attribute(etype, attrname, commit=True)`, removes an attribute from an + existing entity type. -* `rename_attribute(etype, oldname, newname, commit=True)`, renomme un attribut +* `rename_attribute(etype, oldname, newname, commit=True)`, rename an attribute -* `add_entity_type(etype, auto=True, commit=True)`, ajoute un nouveau type - d'entité. Si `auto` est vrai, toutes les relations utilisant ce type d'entité - et ayant un type d'entité connu à l'autre extrémité vont également être - ajoutées. +* `add_entity_type(etype, auto=True, commit=True)`, adds a new entity type. + If `auto` is True, all the relations using this entity type and having a known + entity type on the other hand will automatically be added. -* `drop_entity_type(etype, commit=True)`, supprime un type d'entité et toutes - les relations l'utilisant. +* `drop_entity_type(etype, commit=True)`, removes an entity type and all the + relations using it. -* `rename_entity_type(oldname, newname, commit=True)`, renomme un type d'entité +* `rename_entity_type(oldname, newname, commit=True)`, renames an entity type -* `add_relation_type(rtype, addrdef=True, commit=True)`, ajoute un nouveau type - de relation. Si `addrdef` est vrai, toutes les définitions de relation de ce - type seront également ajoutées. +* `add_relation_type(rtype, addrdef=True, commit=True)`, adds a new relation + type. If `addrdef` is True, all the relations definitions of this type will + be added. + +* `drop_relation_type(rtype, commit=True)`, removes a relation type and all the + definitions of this type. -* `drop_relation_type(rtype, commit=True)`, supprime un type de relation et - toutes les définitions de ce type. +* `rename_relation(oldname, newname, commit=True)`, renames a relation. + +* `add_relation_definition(subjtype, rtype, objtype, commit=True)`, adds a new + relation definition. + +* `drop_relation_definition(subjtype, rtype, objtype, commit=True)`, removes + a relation definition. -* `rename_relation(oldname, newname, commit=True)`, renomme une relation. - -* `add_relation_definition(subjtype, rtype, objtype, commit=True)`, ajoute une - définition de relation. - -* `drop_relation_definition(subjtype, rtype, objtype, commit=True)`, supprime - une définition de relation. - -* `synchronize_permissions(ertype, commit=True)`, synchronise les permissions - d'un type d'entité ou de relation +* `synchronize_permissions(ertype, commit=True)`, synchronizes permissions on + an entity type or relation type. -* `synchronize_rschema(rtype, commit=True)`, synchronise les propriétés et - permissions d'un type de relation. +* `synchronize_rschema(rtype, commit=True)`, synchronizes properties and permissions + on a relation type. -* `synchronize_eschema(etype, commit=True)`, synchronise les propriétés et - permissions d'un type d'entité. +* `synchronize_eschema(etype, commit=True)`, synchronizes properties and persmissions + on an entity type. -* `synchronize_schema(commit=True)`, synchronise le schéma persistent avec le - schéma à jour (mais sans ajouter ni supprimer de nouveaux types d'entités ou - de relations ni de définitions de relation). +* `synchronize_schema(commit=True)`, synchronizes the persisting schema with the + updated schema (but without adding or removing new entity types, relations types + or even relations definitions). -* `change_relation_props(subjtype, rtype, objtype, commit=True, **kwargs)`, change - les propriétés d'une definition de relation en utilisant les arguments nommés - pour les propriétés à changer. +* `change_relation_props(subjtype, rtype, objtype, commit=True, **kwargs)`, changes + properties of a relation definition by using the nammed parameters of the properties + to change. + +* `set_widget(etype, rtype, widget, commit=True)`, changes the widget used for the + relation of entity type . + +* `set_size_constraint(etype, rtype, size, commit=True)`, changes the size constraints + for the relation of entity type . + +Data migration +-------------- +The following functions for data migration are available in the `repository` scripts: + +* `rql(rql, kwargs=None, cachekey=None, ask_confirm=True)`, executes an arbitrary RQL + query, either to interrogate or update. A result set object is returned. + +* `add_entity(etype, *args, **kwargs)`, adds a nes entity type of the given + type. The attributes and relations values are specified using the nammed and + positionned parameters. + +Workflow creation +----------------- -* `set_widget(etype, rtype, widget, commit=True)`, change le widget à utiliser - pour la relation du type d'entité +The following functions for workflow creation are available in the `repository` +scripts: + +* `add_state(name, stateof, initial=False, commit=False, **kwargs)`, adds a new state + in the workflow. + +* `add_transition(name, transitionof, fromstates, tostate, requiredgroups=(), commit=False, **kwargs)`, + adds a new transition in the workflow. + +You can find more details about workflows in the chapter :ref:`Workflow` . -* `set_size_constraint(etype, rtype, size, commit=True)`, change la contrainte - de taille pour la relation du type d'entité +Configuration migration +----------------------- + +The following functions for configuration migration are available in all the +scripts: + +* `option_renamed(oldname, newname)`, indicates that an option has been renammed + +* `option_group_change(option, oldgroup, newgroup)`, indicates that an option does not + belong anymore to the same group. + +* `option_added(oldname, newname)`, indicates that an option has been added. + +* `option_removed(oldname, newname)`, indicates that an option has been deleted. -Migration de données --------------------- -Les fonctions de migration de données suivantes sont disponibles dans les scripts -"repository" : - -* `rql(rql, kwargs=None, cachekey=None, ask_confirm=True)`, éxécute une - requête rql arbitraire, d'interrogation ou de modification. Un objet result - set est retourné. - -* `add_entity(etype, *args, **kwargs)`, ajoute une nouvelle entité du type - données. La valeur des attributs et relations est spécifiée en utilisant les - arguments nommés et positionnels. - - -Création de workflow --------------------- -Les fonctions de création de workflow suivantes sont disponibles dans les scripts -"repository" : - -* `add_state(name, stateof, initial=False, commit=False, **kwargs)`, ajoute un - nouvel état de workflow - -* `add_transition(name, transitionof, fromstates, tostate, requiredgroups=(), commit=False, **kwargs)`, - ajoute une nouvelle transtion de workflow +Others migration functions +-------------------------- +Those functions are only used for low level operations that could not be +accomplished otherwise or to repair damaged databases during interactive +session. They are available in the `repository` scripts: -Migration de configuration --------------------------- -Les fonctions de migration de configuration suivantes sont disponibles dans tout -les scripts : - -* `option_renamed(oldname, newname)`, indique qu'une option a été renommée - -* `option_group_change(option, oldgroup, newgroup)`, indique qu'une option a - changé de groupe - -* `option_added(oldname, newname)`, indique qu'une option a été ajoutée - -* `option_removed(oldname, newname)`, indique qu'une option a été supprimée - - -Autres fonctions de migration ------------------------------ -Ces fonctions ne sont utilisés que pour des opérations de bas niveau -irréalisables autrement ou pour réparer des bases cassées lors de session -interactive. Elles sont disponibles dans les scripts "repository". - -* `sqlexec(sql, args=None, ask_confirm=True)`, éxécute une requête sql - arbitraire, à n'utiliser - +* `sqlexec(sql, args=None, ask_confirm=True)`, executes an arbitrary SQL query * `add_entity_type_table(etype, commit=True)` * `add_relation_type_table(rtype, commit=True)` * `uninline_relation(rtype, commit=True)`