Modifications entre les versions 4 et 6 (s'étendant sur 2 versions)
Version 4 à la date du 2013-08-29 16:32:17
Taille: 5312
Commentaire:
Version 6 à la date du 2013-08-29 16:41:44
Taille: 5738
Commentaire:
Texte supprimé. Texte ajouté.
Ligne 5: Ligne 5:
{{{ source atelier/bin/activtate }}}
{{{
source atelier/bin/activtate
}}}
Ligne 86: Ligne 89:
Ligne 87: Ligne 91:
Ligne 91: Ligne 94:
  * {{ python manage.py startapp catalogue }} {{{
python manage.py startapp catalogue
}}}
Ligne 104: Ligne 109:
* création du modèle Formation dans catalogue/models.py
Ligne 105: Ligne 111:
* création du modèle Formation dans catalogue/models.py
Ligne 119: Ligne 124:
X-( [[https://github.com/olarcheveque/atelier-south-inspectdb/blob/6d153c1c3c4329720fe70a4dc5de6df5a91d41fd/catalogue/migrations/0003_recuperation_id_intitule.py#L9 ]]
Ligne 122: Ligne 126:
Itération 2 (création des universités à partir de l'existant)
------------------------------------------------------------
X-( [[https://github.com/olarcheveque/atelier-south-inspectdb/blob/6d153c1c3c4329720fe70a4dc5de6df5a91d41fd/catalogue/migrations/0003_recuperation_id_intitule.py#L9 ]]


== Itération 2 (création des universités à partir de l'existant) ==
Ligne 125: Ligne 131:
* python manage.py schemamigration catalogue --auto
* python manage.py migrate catalogue
* python manage.py datamigration catalogue creation_universite --freeze ancien
* python manage.py migrate catalogue
{{{
python manage.py schemamigration catalogue --auto
python manage.py migrate catalogue
}}}
{{{
python manage.py datamigration catalogue creation_universite --freeze ancien
}}}
X-( [[https://github.com/olarcheveque/atelier-south-inspectdb/blob/cd81764142cce07ee2fb050e237a73f2815eb17c/catalogue/models.py]]
{{{
python manage.py migrate catalogue
}}}
X-( [[https://github.com/olarcheveque/atelier-south-inspectdb/blob/master/catalogue/migrations/0005_creation_universite.py#L9]]
Ligne 130: Ligne 144:
Itération 3 (création des domaines à partir de l'existant)
------------------------------------------------------------
== Itération 3 (création des domaines à partir de l'existant) ==
Ligne 133: Ligne 146:
* python manage.py schemamigration catalogue --auto
* python manage.py migrate catalogue
* python manage.py datamigration catalogue creation_domaine --freeze ancien
* python manage.py migrate catalogue
X-( [[https://github.com/olarcheveque/atelier-south-inspectdb/blob/master/catalogue/models.py#L20]]
{{{
python manage.py schemamigration catalogue --auto
python manage.py migrate catalogue
}}}
Ligne 138: Ligne 152:
Commandes utiles
----------------
{{{
python manage.py datamigration catalogue creation_domaine --freeze ancien
}}}
X-( [[https://github.com/olarcheveque/atelier-south-inspectdb/blob/master/catalogue/migrations/0007_creation_domaine.py#L9]]
{{{
python manage.py migrate catalogue
}}}

= Commandes utiles =
Ligne 144: Ligne 166:
* python manage.py sqlclear catalogue > del_catalogue
* mysql -u o -p --database=atelier < del_catalogue
* python manage.py dbshell
{{{
python manage.py sqlclear catalogue > del_catalogue
mysql -u <user> -p --database=atelier < del_catalogue
python manage.py dbshell
Ligne 148: Ligne 171:
}}}

Chargement de l'environnement virtuel

(Voir les prérequis de l'atelier)

source atelier/bin/activtate

Création d'un projet Django

Boostrap

python manage.py startproject foad
cd foad
python manage.py runserver (CTRL+C)
echo "*.pyc" > .gitignore
git init
git add .
git commit -m 'nouveau projet'

{OK} à chaque modification correcte au cours de l'atelier, commiter-les, vous pourrez plus facilement voir les modifications de fichiers, revenir en arrière, etc...

Base de données MySQL

python manage.py syncdb

(créer le superuser)

Activation de l'admin

Exploiter l'existant

Création de l'application

django-admin.py startapp ancien

Câblage db

Câblage de l'ancien dans l'admin

Nouveau système

python manage.py startapp catalogue
  • dans 'foad/settings.py':
    • variable INSTALLED_APPS, ajouter votre nouvelle application: 'catalogue'

initialisation du framework de migration pour l'app

python manage.py schemamigration catalogue --initial
python manage.py migrate catalogue

Création du script de modification de BD selon le modèle

* création du modèle Formation dans catalogue/models.py

X-( https://github.com/olarcheveque/atelier-south-inspectdb/blob/6d153c1c3c4329720fe70a4dc5de6df5a91d41fd/catalogue/models.py

python manage.py schemamigration catalogue --auto
python manage.py migrate catalogue

* création d'un fichier catalogue/admin.py X-( https://github.com/olarcheveque/atelier-south-inspectdb/blob/6d153c1c3c4329720fe70a4dc5de6df5a91d41fd/catalogue/admin.py

Itération 1 (création des formations à partir de l'existant)

python manage.py datamigration catalogue recuperation_id_intitule  --freeze ancien

X-( https://github.com/olarcheveque/atelier-south-inspectdb/blob/6d153c1c3c4329720fe70a4dc5de6df5a91d41fd/catalogue/migrations/0003_recuperation_id_intitule.py#L9

Itération 2 (création des universités à partir de l'existant)

* ajout du modèle Universite dans catalogue/models.py

python manage.py schemamigration catalogue --auto
python manage.py migrate catalogue

python manage.py datamigration catalogue creation_universite  --freeze ancien

X-( https://github.com/olarcheveque/atelier-south-inspectdb/blob/cd81764142cce07ee2fb050e237a73f2815eb17c/catalogue/models.py

python manage.py migrate catalogue

X-( https://github.com/olarcheveque/atelier-south-inspectdb/blob/master/catalogue/migrations/0005_creation_universite.py#L9

Itération 3 (création des domaines à partir de l'existant)

* ajout du modèle Universite dans catalogue/models.py X-( https://github.com/olarcheveque/atelier-south-inspectdb/blob/master/catalogue/models.py#L20

python manage.py schemamigration catalogue --auto
python manage.py migrate catalogue

python manage.py datamigration catalogue creation_domaine  --freeze ancien

X-( https://github.com/olarcheveque/atelier-south-inspectdb/blob/master/catalogue/migrations/0007_creation_domaine.py#L9

python manage.py migrate catalogue

Commandes utiles

En cas, d'une migration échouée, comme les modifications ne sont pas transactionnelle, il est bon re resetter l'application dans un état stable, corrélé avec les modèles.

python manage.py sqlclear catalogue > del_catalogue
mysql -u <user> -p --database=atelier < del_catalogue
python manage.py dbshell
  - delete from south_migrationhistory where app_name = 'catalogue';

Projet/SemaineTech/2013/Ateliers/DjangoInspectdbSouth/Support (dernière édition le 2013-09-06 13:09:42 par DavinBaragiotta)