Skip to content

Commit 7b4ed2a

Browse files
fix
1 parent e9164ba commit 7b4ed2a

File tree

3 files changed

+62
-20
lines changed

3 files changed

+62
-20
lines changed
Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""preparation for osparc.io migration
22
3-
Revision ID: 1a791d837399
3+
Revision ID: f4c938f80040
44
Revises: b39f2dc87ccd
5-
Create Date: 2025-05-19 13:09:24.279828+00:00
5+
Create Date: 2025-05-19 14:30:09.366828+00:00
66
77
"""
88

@@ -11,7 +11,7 @@
1111
from sqlalchemy.dialects import postgresql
1212

1313
# revision identifiers, used by Alembic.
14-
revision = "1a791d837399"
14+
revision = "f4c938f80040"
1515
down_revision = "b39f2dc87ccd"
1616
branch_labels = None
1717
depends_on = None
@@ -107,6 +107,26 @@ def upgrade():
107107
)
108108
op.drop_index("ix_projects_comments_project_uuid", table_name="projects_comments")
109109
op.drop_table("projects_comments")
110+
op.drop_constraint("api_keys_user_id_fkey", "api_keys", type_="foreignkey")
111+
op.create_foreign_key(
112+
None,
113+
"api_keys",
114+
"users",
115+
["user_id"],
116+
["id"],
117+
onupdate="CASCADE",
118+
ondelete="CASCADE",
119+
)
120+
op.drop_constraint("user_confirmation_fkey", "confirmations", type_="foreignkey")
121+
op.create_foreign_key(
122+
"user_confirmation_fkey",
123+
"confirmations",
124+
"users",
125+
["user_id"],
126+
["id"],
127+
onupdate="CASCADE",
128+
ondelete="CASCADE",
129+
)
110130
op.drop_column("file_meta_data", "node_id")
111131
op.drop_constraint("fk_new_folders_to_groups_gid", "folders_v2", type_="foreignkey")
112132
op.drop_constraint("fk_new_folders_to_folders_id", "folders_v2", type_="foreignkey")
@@ -154,6 +174,15 @@ def upgrade():
154174
onupdate="CASCADE",
155175
ondelete="CASCADE",
156176
)
177+
op.create_foreign_key(
178+
"fk_payments_transactions_to_wallet_id",
179+
"payments_transactions",
180+
"wallets",
181+
["wallet_id"],
182+
["wallet_id"],
183+
onupdate="CASCADE",
184+
ondelete="CASCADE",
185+
)
157186
op.create_foreign_key(
158187
"fk_payments_transactions_to_products_name",
159188
"payments_transactions",
@@ -172,15 +201,6 @@ def upgrade():
172201
onupdate="CASCADE",
173202
ondelete="CASCADE",
174203
)
175-
op.create_foreign_key(
176-
"fk_payments_transactions_to_wallet_id",
177-
"payments_transactions",
178-
"wallets",
179-
["wallet_id"],
180-
["wallet_id"],
181-
onupdate="CASCADE",
182-
ondelete="CASCADE",
183-
)
184204
op.create_foreign_key(
185205
"fk_service_runs_to_product_name",
186206
"resource_tracker_service_runs",
@@ -213,17 +233,17 @@ def downgrade():
213233
type_="foreignkey",
214234
)
215235
op.drop_constraint(
216-
"fk_payments_transactions_to_wallet_id",
236+
"fk_payments_transactions_to_user_id",
217237
"payments_transactions",
218238
type_="foreignkey",
219239
)
220240
op.drop_constraint(
221-
"fk_payments_transactions_to_user_id",
241+
"fk_payments_transactions_to_products_name",
222242
"payments_transactions",
223243
type_="foreignkey",
224244
)
225245
op.drop_constraint(
226-
"fk_payments_transactions_to_products_name",
246+
"fk_payments_transactions_to_wallet_id",
227247
"payments_transactions",
228248
type_="foreignkey",
229249
)
@@ -259,6 +279,24 @@ def downgrade():
259279
"file_meta_data",
260280
sa.Column("node_id", sa.VARCHAR(), autoincrement=False, nullable=True),
261281
)
282+
op.drop_constraint("user_confirmation_fkey", "confirmations", type_="foreignkey")
283+
op.create_foreign_key(
284+
"user_confirmation_fkey",
285+
"confirmations",
286+
"users",
287+
["user_id"],
288+
["id"],
289+
ondelete="CASCADE",
290+
)
291+
op.drop_constraint(None, "api_keys", type_="foreignkey")
292+
op.create_foreign_key(
293+
"api_keys_user_id_fkey",
294+
"api_keys",
295+
"users",
296+
["user_id"],
297+
["id"],
298+
ondelete="CASCADE",
299+
)
262300
op.create_table(
263301
"projects_comments",
264302
sa.Column("comment_id", sa.BIGINT(), autoincrement=True, nullable=False),

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
sa.Column(
3838
"user_id",
3939
sa.BigInteger(),
40-
sa.ForeignKey(users.c.id, ondelete=RefActions.CASCADE),
40+
sa.ForeignKey(
41+
users.c.id, ondelete=RefActions.CASCADE, onupdate=RefActions.CASCADE
42+
),
4143
nullable=False,
4244
doc="Identified user",
4345
),

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
""" User's confirmations table
1+
"""User's confirmations table
22
3-
- Keeps a list of tokens to identify an action (registration, invitation, reset, etc) authorized
4-
by link to a a user in the framework
5-
- These tokens have an expiration date defined by configuration
3+
- Keeps a list of tokens to identify an action (registration, invitation, reset, etc) authorized
4+
by link to a a user in the framework
5+
- These tokens have an expiration date defined by configuration
66
77
"""
8+
89
import enum
910

1011
import sqlalchemy as sa
@@ -61,6 +62,7 @@ class ConfirmationAction(enum.Enum):
6162
["user_id"],
6263
[users.c.id],
6364
name="user_confirmation_fkey",
65+
onupdate=RefActions.CASCADE,
6466
ondelete=RefActions.CASCADE,
6567
),
6668
)

0 commit comments

Comments
 (0)