11"""preparation for osparc.io migration
22
3- Revision ID: 1a791d837399
3+ Revision ID: f4c938f80040
44Revises: 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
1111from sqlalchemy .dialects import postgresql
1212
1313# revision identifiers, used by Alembic.
14- revision = "1a791d837399 "
14+ revision = "f4c938f80040 "
1515down_revision = "b39f2dc87ccd"
1616branch_labels = None
1717depends_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 ),
0 commit comments