Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erreur SQL lors du déploiement en PROD de la v15.1 #3304

Closed
SpaceFox opened this issue Jan 15, 2016 · 6 comments
Closed

Erreur SQL lors du déploiement en PROD de la v15.1 #3304

SpaceFox opened this issue Jan 15, 2016 · 6 comments
Labels
Bloquant Ticket qui doit être traité avant la prochaine mise à jour C-Back Concerne le back-end Django S-Régression Corrige un problème sur un composant qui fonctionnait auparavant
Milestone

Comments

@SpaceFox
Copy link
Contributor

À priori, c'est pas en bêta, ce qui me fait encore plus flipper…

Operations to perform:
  Synchronize unmigrated apps: corsheaders, raven_contrib_django, captcha, munin, debug_toolbar, sitemaps, rest_framework_swagger, rest_framework, haystack, crispy_forms
  Apply all migrations: oauth2_provider, search, tutorialv2, forum, sessions, admin, utils, featured, auth, gallery, member, default, contenttypes, mp, sites, article, easy_thumbnails, tutorial
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying oauth2_provider.0002_08_updates...Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/raven/contrib/django/management/__init__.py", line 41, in new_execute
    return original_func(self, *args, **kwargs)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 161, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 68, in migrate
    self.apply_migration(migration, fake=fake)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 102, in apply_migration
    migration.apply(project_state, schema_editor)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 108, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 37, in database_forwards
    field,
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/backends/mysql/schema.py", line 42, in add_field
    super(DatabaseSchemaEditor, self).add_field(model, field)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 388, in add_field
    self.execute(sql, params)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 111, in execute
    cursor.execute(sql, params)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 129, in execute
    return self.cursor.execute(query, args)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/opt/zdsenv/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.OperationalError: (1060, "Duplicate column name 'skip_authorization'")
Sentry is attempting to send 2 pending error messages
Waiting up to 10 seconds
Press Ctrl-C to quit

À noter que ça n'empêche pas le déploiement en prod et l'application de tourner. C'est « juste » qu'on a une colonne en trop dans notre BDD de prod, et donc des migrations qui ne correspondent pas à la base.

J'aimerais savoir par quel miracle c'est possible…

@SpaceFox SpaceFox added S-Régression Corrige un problème sur un composant qui fonctionnait auparavant C-Back Concerne le back-end Django Bloquant Ticket qui doit être traité avant la prochaine mise à jour labels Jan 15, 2016
@SpaceFox
Copy link
Contributor Author

Sentry pour ceux qui y ont accès : #3303

@gustavi
Copy link
Contributor

gustavi commented Jan 16, 2016

Potentiellement on doit pouvoir rajouter un truc comme ça à Travis pour check :

check_migrations()
{
    if [[ $(python manage.py makemigrations) ]]; then
        echo "You forgot to create migrations. Please run python manage.py makemigrations !" >&2
        exit 1
    fi
}

@SpaceFox
Copy link
Contributor Author

Après une étude et une discussion dont les détails ne sont pas très passionnants, il semblerait que ce soit un problème avec les migrations de oauth2_provider, et on se retrouve avec une colonne en trop dans la BDD. Colonne qui ne contient que la valeur par défaut. De plus, on a aucun problème à lancer les migrations sur une base propre - signe que les migrations sont cohérentes.

Voici ce qu'on va faire :

  1. Si quelqu'un a une idée plus intelligente que ce qui est proposé, il a jusqu'à la MEP de la v16 pour la proposer
  2. Avant le lancement du déploiement, vérifier si la colonne oauth2_provider_application.skip_authorization existe. Si oui, la supprimer. (On trouve des problèmes similaires sur le net, les solutions proposées sont celle-ci, ou des versions compliquées de celle-ci)
  3. Lancer le déploiement.
  4. Si le problème ou un problème se reproduit, cf https://docs.djangoproject.com/fr/1.7/topics/migrations/#upgrading-from-south

@gustavi j'ai oublié un truc important ?

@gustavi
Copy link
Contributor

gustavi commented Jan 17, 2016

Non c'est bon. On rajoutera que c'est toujours la même lib qui est chiante.

@GerardPaligot
Copy link
Member

@SpaceFox Pour résoudre l'issue, tu veux une PR qui décrit quelque part la procédure à appliquer si on rencontre ce problème ?

@SpaceFox
Copy link
Contributor Author

Je peux la faire, c'est juste qu'il faut que je trouve la demi-heure nécessaire.

SpaceFox added a commit that referenced this issue Jan 21, 2016
Fix #3304 - colonne en trop dans une table
@SpaceFox SpaceFox added this to the Version 16 milestone Jan 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bloquant Ticket qui doit être traité avant la prochaine mise à jour C-Back Concerne le back-end Django S-Régression Corrige un problème sur un composant qui fonctionnait auparavant
Projects
None yet
Development

No branches or pull requests

3 participants