From cab4984624c2960d5d3abfac211d56a8156af540 Mon Sep 17 00:00:00 2001 From: Maxime Vergez <85738261+mvergez@users.noreply.github.com> Date: Fri, 13 Jan 2023 09:32:29 +0100 Subject: [PATCH] Fix/db migrations (#31) * feat(db): upgrade down_revision following rebase Since rebase with develop: changed the down_revision number * fix(db): fix bind params enabling downgrade Beforehand the downgrade was not possible... * refactor(db): removed cor_site_type_category * refactor(db): changed category into type in cor * refactor(db): create cor_type_site * fix(db): renamed column * refactor(api): update models to fit migrations * fix(db):change bib_categorie_site to bib_type_site Adding : cor_site_module cor_site_type revision alembic to create function and trigger in order to add bib_type_site but only with nomenclature 'TYPE_SITE' upgrade and downgrade works [Refs ticket]: #3 Reviewed-by: andriac * fix(api): updated models from migrations * fix(api): wip: fix admin following migrations * fix(api): update routes and tests To match migration changes * feat: flask admin bib_type_site Change bib_categories to bib_type_site into flask admin Adding filtering in list label_fr of type_site to secure the unique constraint Reviewed-by: andriac [Refs ticket]: #3 * fix(api): updated schema to match models * fix(api): module edition * style(api): uniformize type_site * style(api): change relationship name for type_site * feat(api): validator admin * fix(api): make unique BibTypeSite in admin * test(api): fix test when existing nomenclatures In database Co-authored-by: Andria Capai --- .../migrations/a54bafb13ce8_create_cor_module_type.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/backend/gn_module_monitoring/migrations/a54bafb13ce8_create_cor_module_type.py b/backend/gn_module_monitoring/migrations/a54bafb13ce8_create_cor_module_type.py index 7fa36fdd1..718194469 100644 --- a/backend/gn_module_monitoring/migrations/a54bafb13ce8_create_cor_module_type.py +++ b/backend/gn_module_monitoring/migrations/a54bafb13ce8_create_cor_module_type.py @@ -25,8 +25,8 @@ def upgrade(): "id_type_site", sa.Integer(), sa.ForeignKey( - f"{monitorings_schema}.bib_type_site.id_nomenclature_type_site", - name="fk_cor_module_type_id_nomenclature_type_site", + f"{monitorings_schema}.bib_type_site.id_nomenclature", + name="fk_cor_module_type_id_nomenclature", ondelete="CASCADE", onupdate="CASCADE", ), @@ -46,11 +46,6 @@ def upgrade(): sa.PrimaryKeyConstraint("id_type_site", "id_module", name="pk_cor_module_type"), schema=monitorings_schema, ) - op.create_table_comment( - "cor_module_type", - "Table d'association des types de sites potentiellement associés à un module", - schema=monitorings_schema, - ) def downgrade():