From a9b3c34fb22bd6db9c99a824033b305e762af357 Mon Sep 17 00:00:00 2001 From: Thibault Coudray <169165300+tcoudray-pass@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:10:31 +0100 Subject: [PATCH] (PC-33658)[API] feat: drop `apiUrl` & `authToken` columns in provider table --- api/alembic_version_conflict_detection.txt | 2 +- ..._b44dae2d1489_drop_provider_api_columns.py | 23 +++++++++++++++++++ api/src/pcapi/core/providers/factories.py | 1 - api/src/pcapi/core/providers/models.py | 11 +-------- .../routes/backoffice/venues/blueprint.py | 1 - .../scripts/rebuild_staging/anonymize.sql | 5 ---- api/tests/core/providers/test_api.py | 1 - 7 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 api/src/pcapi/alembic/versions/20250110T100616_b44dae2d1489_drop_provider_api_columns.py diff --git a/api/alembic_version_conflict_detection.txt b/api/alembic_version_conflict_detection.txt index 00f0bbc61d6..7da029fcb78 100644 --- a/api/alembic_version_conflict_detection.txt +++ b/api/alembic_version_conflict_detection.txt @@ -1,2 +1,2 @@ f0b5bf6e0d3f (pre) (head) -64c8345d8d49 (post) (head) +b44dae2d1489 (post) (head) diff --git a/api/src/pcapi/alembic/versions/20250110T100616_b44dae2d1489_drop_provider_api_columns.py b/api/src/pcapi/alembic/versions/20250110T100616_b44dae2d1489_drop_provider_api_columns.py new file mode 100644 index 00000000000..6c9ae805315 --- /dev/null +++ b/api/src/pcapi/alembic/versions/20250110T100616_b44dae2d1489_drop_provider_api_columns.py @@ -0,0 +1,23 @@ +"""Drop `apiUrl` & `authToken` columns in provider table +""" + +from alembic import op +import sqlalchemy as sa + + +# pre/post deployment: post +# revision identifiers, used by Alembic. +revision = "b44dae2d1489" +down_revision = "64c8345d8d49" +branch_labels: tuple[str] | None = None +depends_on: list[str] | None = None + + +def upgrade() -> None: + op.drop_column("provider", "authToken") + op.drop_column("provider", "apiUrl") + + +def downgrade() -> None: + op.add_column("provider", sa.Column("apiUrl", sa.VARCHAR(), autoincrement=False, nullable=True)) + op.add_column("provider", sa.Column("authToken", sa.VARCHAR(), autoincrement=False, nullable=True)) diff --git a/api/src/pcapi/core/providers/factories.py b/api/src/pcapi/core/providers/factories.py index 8044c50b834..2125ffa67a3 100644 --- a/api/src/pcapi/core/providers/factories.py +++ b/api/src/pcapi/core/providers/factories.py @@ -44,7 +44,6 @@ class Meta: name = factory.Sequence("Provider {}".format) localClass = factory.Sequence("{}Stocks".format) hmacKey = "secret" - apiUrl = None enabledForPro = True isActive = True diff --git a/api/src/pcapi/core/providers/models.py b/api/src/pcapi/core/providers/models.py index 98ae5408772..f4b2abff211 100644 --- a/api/src/pcapi/core/providers/models.py +++ b/api/src/pcapi/core/providers/models.py @@ -26,16 +26,7 @@ class Provider(PcObject, Base, Model, DeactivableMixin): name: str = sa.Column(sa.String(90), index=True, nullable=False) - localClass = sa.Column( - sa.String(60), - nullable=True, - unique=True, - ) - - # presence of this field signifies the provider implements pass Culture's provider API - apiUrl = sa.Column(sa.String, nullable=True) - - authToken = sa.Column(sa.String, nullable=True) + localClass = sa.Column(sa.String(60), nullable=True, unique=True) enabledForPro: bool = sa.Column(sa.Boolean, nullable=False, default=False, server_default=sa_sql.expression.false()) diff --git a/api/src/pcapi/routes/backoffice/venues/blueprint.py b/api/src/pcapi/routes/backoffice/venues/blueprint.py index 4b1f5c1ffef..8a1bb615c14 100644 --- a/api/src/pcapi/routes/backoffice/venues/blueprint.py +++ b/api/src/pcapi/routes/backoffice/venues/blueprint.py @@ -154,7 +154,6 @@ def get_venue(venue_id: int) -> offerers_models.Venue: providers_models.Provider.id, providers_models.Provider.name, providers_models.Provider.localClass, - providers_models.Provider.apiUrl, providers_models.Provider.isActive, ), sa.orm.joinedload(offerers_models.Venue.accessibilityProvider).load_only( diff --git a/api/src/pcapi/scripts/rebuild_staging/anonymize.sql b/api/src/pcapi/scripts/rebuild_staging/anonymize.sql index ccfbb34baad..b20dfdbc204 100644 --- a/api/src/pcapi/scripts/rebuild_staging/anonymize.sql +++ b/api/src/pcapi/scripts/rebuild_staging/anonymize.sql @@ -94,11 +94,6 @@ UPDATE invoice SET token = 'anonymized-' || id::text; UPDATE activation_code SET code = 'FAKE-' || id::text ; -UPDATE provider -SET "authToken" = 'anonymized, you may have to set it if you want to use this provider' -WHERE "authToken" IS NOT NULL -; - UPDATE provider SET "bookingExternalUrl" = 'http://mock-api-billeterie.mock-api-billeterie.svc.cluster.local:5003/tickets/create', diff --git a/api/tests/core/providers/test_api.py b/api/tests/core/providers/test_api.py index 07c0f1d3fa3..e1a3a9be552 100644 --- a/api/tests/core/providers/test_api.py +++ b/api/tests/core/providers/test_api.py @@ -65,7 +65,6 @@ def test_permanent_venue_marking( provider = providers_factories.ProviderFactory( enabledForPro=True, isActive=True, - apiUrl="https://example.com/api", localClass=None, ) author = users_factories.UserFactory()