Skip to content

Commit 81d1663

Browse files
add ondelete restriction to pricing plan to service DB table
1 parent 8c581ea commit 81d1663

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

packages/postgres-database/src/simcore_postgres_database/migration/versions/bc9c46960430_add_restriction_ondelete.py renamed to packages/postgres-database/src/simcore_postgres_database/migration/versions/d84edab53761_add_restriction_ondelete.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
"""add restriction ondelete
22
3-
Revision ID: bc9c46960430
3+
Revision ID: d84edab53761
44
Revises: 163b11424cb1
5-
Create Date: 2025-02-25 08:25:05.439960+00:00
5+
Create Date: 2025-02-25 09:18:14.541874+00:00
66
77
"""
88
from alembic import op
99

1010
# revision identifiers, used by Alembic.
11-
revision = "bc9c46960430"
11+
revision = "d84edab53761"
1212
down_revision = "163b11424cb1"
1313
branch_labels = None
1414
depends_on = None
1515

1616

1717
def upgrade():
1818
# ### commands auto generated by Alembic - please adjust! ###
19+
op.create_unique_constraint(
20+
"uq_licensed_item_to_resource_resource_id",
21+
"licensed_item_to_resource",
22+
["licensed_resource_id"],
23+
)
1924
op.drop_constraint(
2025
"fk_rut_pricing_plan_to_service_key_and_version",
2126
"resource_tracker_pricing_plan_to_service",
@@ -49,4 +54,9 @@ def downgrade():
4954
onupdate="CASCADE",
5055
ondelete="CASCADE",
5156
)
57+
op.drop_constraint(
58+
"uq_licensed_item_to_resource_resource_id",
59+
"licensed_item_to_resource",
60+
type_="unique",
61+
)
5262
# ### end Alembic commands ###

packages/postgres-database/src/simcore_postgres_database/models/licensed_item_to_resource.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,13 @@
3131
),
3232
column_created_datetime(timezone=True),
3333
column_modified_datetime(timezone=True),
34+
#########
35+
# NOTE: Currently, there is a constraint that a resource item ID cannot be in multiple licensed items.
36+
# The reason is that the license key and license version coming from the internal license server are part of the licensed resource domain.
37+
# Sim4Life performs a mapping on their side, where the license key and version are mapped to a licensed item.
38+
# If this constraint is broken, the mapping logic in Sim4Life might break.
39+
sa.UniqueConstraint(
40+
"licensed_resource_id",
41+
name="uq_licensed_item_to_resource_resource_id",
42+
),
3443
)

0 commit comments

Comments
 (0)