diff --git a/packages/models-library/src/models_library/licensed_items.py b/packages/models-library/src/models_library/licensed_items.py index b65cd86805a..021cf214ce5 100644 --- a/packages/models-library/src/models_library/licensed_items.py +++ b/packages/models-library/src/models_library/licensed_items.py @@ -1,6 +1,7 @@ from datetime import datetime from enum import auto from typing import TypeAlias +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field @@ -8,7 +9,7 @@ from .resource_tracker import PricingPlanId from .utils.enums import StrAutoEnum -LicensedItemID: TypeAlias = str +LicensedItemID: TypeAlias = UUID class LicensedResourceType(StrAutoEnum): diff --git a/packages/postgres-database/src/simcore_postgres_database/migration/versions/e5555076ef50_add_license_db_tables.py b/packages/postgres-database/src/simcore_postgres_database/migration/versions/e5555076ef50_add_license_db_tables.py index ba4c6007be9..abdfafefdf7 100644 --- a/packages/postgres-database/src/simcore_postgres_database/migration/versions/e5555076ef50_add_license_db_tables.py +++ b/packages/postgres-database/src/simcore_postgres_database/migration/versions/e5555076ef50_add_license_db_tables.py @@ -17,13 +17,28 @@ def upgrade(): + # CREATE EXTENSION pgcrypto; + op.execute( + """ + DO + $$ + BEGIN + IF EXISTS(SELECT * FROM pg_available_extensions WHERE name = 'pgcrypto') THEN + -- Create the extension + CREATE EXTENSION if not exists pgcrypto; + END IF; + END + $$; + """ + ) + # ### commands auto generated by Alembic - please adjust! ### op.create_table( "resource_tracker_licensed_items_purchases", sa.Column( "licensed_item_purchase_id", postgresql.UUID(as_uuid=True), - server_default="gen_random_uuid()", + server_default=sa.text("gen_random_uuid()"), nullable=False, ), sa.Column("product_name", sa.String(), nullable=False), @@ -61,7 +76,7 @@ def upgrade(): sa.Column( "licensed_item_usage_id", postgresql.UUID(as_uuid=True), - server_default="gen_random_uuid()", + server_default=sa.text("gen_random_uuid()"), nullable=False, ), sa.Column("licensed_item_id", sa.String(), nullable=True), @@ -102,7 +117,7 @@ def upgrade(): sa.Column( "licensed_item_id", postgresql.UUID(as_uuid=True), - server_default="gen_random_uuid()", + server_default=sa.text("gen_random_uuid()"), nullable=False, ), sa.Column("name", sa.String(), nullable=False), diff --git a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml index dc6c68bed39..829aa2be9c2 100644 --- a/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml +++ b/services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml @@ -2404,6 +2404,7 @@ paths: required: true schema: type: string + format: uuid title: Licensed Item Id responses: '200': @@ -2431,6 +2432,7 @@ paths: required: true schema: type: string + format: uuid title: Licensed Item Id requestBody: required: true @@ -10011,11 +10013,12 @@ components: properties: licensedItemId: type: string + format: uuid title: Licenseditemid name: type: string title: Name - licenseResourceType: + licensedResourceType: $ref: '#/components/schemas/LicensedResourceType' pricingPlanId: type: integer @@ -10034,7 +10037,7 @@ components: required: - licensedItemId - name - - licenseResourceType + - licensedResourceType - pricingPlanId - createdAt - modifiedAt diff --git a/services/web/server/tests/unit/with_dbs/04/licenses/test_licensed_items_handlers.py b/services/web/server/tests/unit/with_dbs/04/licenses/test_licensed_items_handlers.py index 535032c31a2..eb63d9bb75a 100644 --- a/services/web/server/tests/unit/with_dbs/04/licenses/test_licensed_items_handlers.py +++ b/services/web/server/tests/unit/with_dbs/04/licenses/test_licensed_items_handlers.py @@ -52,7 +52,7 @@ async def test_licensed_items_db_crud( # get url = client.app.router["get_licensed_item"].url_for( - licensed_item_id=_licensed_item_id + licensed_item_id=f"{_licensed_item_id}" ) resp = await client.get(f"{url}") data, _ = await assert_status(resp, status.HTTP_200_OK) @@ -60,7 +60,7 @@ async def test_licensed_items_db_crud( # purchase url = client.app.router["purchase_licensed_item"].url_for( - licensed_item_id=_licensed_item_id + licensed_item_id=f"{_licensed_item_id}" ) resp = await client.post(f"{url}", json={"wallet_id": 1, "num_of_seeds": 5}) # NOTE: Not yet implemented