Club-Alpin-Annecy / collectives

Site de collectives du caf Annecy
https://doc.collectives.cafannecy.fr
15 stars 19 forks source link

Upgrade of DB fails #686

Closed jnguiot closed 4 months ago

jnguiot commented 4 months ago

On test.collectives.cafannecy.fr, the DB upgrade for 01e584e fails. The failing file is https://github.com/Club-Alpin-Annecy/collectives/blob/master/migrations/versions/4a8c2871e259_add_questions.py

The error is

2024-03-09 13:43:24,803 INFO collectives MainThread : Populating database with initial values datefmt=
2024-03-09 13:43:24,886 INFO collectives MainThread : Absent configuration item PAYMENTS_TERMS_FILE: creating datefmt=
Traceback (most recent call last):
 [...]
  File "/home/demo/collectives-flask2/.env/lib/python3.9/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.DataError: (1265, "Data truncated for column 'type' at row 1")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):[...]
sqlalchemy.exc.DataError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(pymysql.err.DataError) (1265, "Data truncated for column 'type' at row 1")
[SQL: UPDATE config SET description=%(description)s, type=%(type)s WHERE config.id = %(config_id)s]
[parameters: {'description': 'File path to the background volunteer certificate image. Empty to deactivate \nvolunteer certificate generation. Dimensions: 2479x3508\n', 'type': 'SecretFile', 'config_id': 45}]
jnguiot commented 4 months ago

Celà semble dû au fait que les init ne détecte pas que le serveur est en migration. Cf https://github.com/Club-Alpin-Annecy/collectives/blob/01e584ea4e8834fd2ea64b259d5802c9d2769f4b/collectives/utils/init.py#L264 En effet, le ctx.command.name ici est flask

jnguiot commented 4 months ago

Apparemment, l'initialisation de l'app se fait avant même l'appel de la commande par click : https://github.com/pallets/flask/blob/b90a4f1f4a370e92054b9cc9db0efcb864f87ebe/src/flask/cli.py#L72C1-L72C36