diff --git a/migrations/versions/3c31bb0b27c9_fix_calais.py b/migrations/versions/3c31bb0b27c9_fix_calais.py new file mode 100644 index 00000000..ad961abe --- /dev/null +++ b/migrations/versions/3c31bb0b27c9_fix_calais.py @@ -0,0 +1,88 @@ +"""fix_calais + +Revision ID: 3c31bb0b27c9 +Revises: d5b3bdd1d622 +Create Date: 2022-06-23 10:48:27.787550 + +Pour réparer les bases auxquelles il manquerait le ref. de comp.: +bug dit "de Calais" + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "3c31bb0b27c9" +down_revision = "d5b3bdd1d622" +branch_labels = None +depends_on = None + + +# Voir https://stackoverflow.com/questions/24082542/check-if-a-table-column-exists-in-the-database-using-sqlalchemy-and-alembic +from sqlalchemy import inspect + + +def column_exists(table_name, column_name): + bind = op.get_context().bind + insp = inspect(bind) + columns = insp.get_columns(table_name) + return any(c["name"] == column_name for c in columns) + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + if not column_exists("apc_competence", "id_orebut"): + op.add_column( + "apc_competence", sa.Column("id_orebut", sa.Text(), nullable=True) + ) + op.create_index( + op.f("ix_apc_competence_id_orebut"), + "apc_competence", + ["id_orebut"], + unique=False, + ) + op.drop_constraint( + "apc_competence_referentiel_id_titre_key", "apc_competence", type_="unique" + ) + if not column_exists("apc_referentiel_competences", "annexe"): + op.add_column( + "apc_referentiel_competences", sa.Column("annexe", sa.Text(), nullable=True) + ) + if not column_exists("apc_referentiel_competences", "type_structure"): + op.add_column( + "apc_referentiel_competences", + sa.Column("type_structure", sa.Text(), nullable=True), + ) + if not column_exists("apc_referentiel_competences", "type_departement"): + op.add_column( + "apc_referentiel_competences", + sa.Column("type_departement", sa.Text(), nullable=True), + ) + if not column_exists("apc_referentiel_competences", "version_orebut"): + op.add_column( + "apc_referentiel_competences", + sa.Column("version_orebut", sa.Text(), nullable=True), + ) + + # op.create_index( + # op.f("ix_scolar_news_authenticated_user"), + # "scolar_news", + # ["authenticated_user"], + # unique=False, + # ) + # op.create_index(op.f("ix_scolar_news_date"), "scolar_news", ["date"], unique=False) + # op.create_index( + # op.f("ix_scolar_news_object"), "scolar_news", ["object"], unique=False + # ) + # op.create_index(op.f("ix_scolar_news_type"), "scolar_news", ["type"], unique=False) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + + # ne fait rien ! ce script est idempotent + pass + # ### end Alembic commands ### diff --git a/sco_version.py b/sco_version.py index be28c9f1..1b8a3078 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.2.25" +SCOVERSION = "9.2.26" SCONAME = "ScoDoc"