forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into update-from-maste…
…r-XXX
- Loading branch information
Showing
28 changed files
with
627 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...imcore_postgres_database/migration/versions/8e1f83486be7_enhance_projects_tags_for_rut.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
"""enhance projects_tags for RUT | ||
Revision ID: 8e1f83486be7 | ||
Revises: 8bfe65a5e294 | ||
Create Date: 2024-11-15 09:12:57.789183+00:00 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "8e1f83486be7" | ||
down_revision = "8bfe65a5e294" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"projects_tags", sa.Column("project_uuid_for_rut", sa.String(), nullable=True) | ||
) | ||
|
||
# Migrate | ||
op.execute( | ||
sa.DDL( | ||
""" | ||
UPDATE projects_tags | ||
SET project_uuid_for_rut = projects.uuid | ||
FROM projects | ||
WHERE projects_tags.project_id = projects.id; | ||
""" | ||
) | ||
) | ||
|
||
op.alter_column( | ||
"projects_tags", | ||
"project_uuid_for_rut", | ||
existing_type=sa.String(), | ||
nullable=False, | ||
) | ||
op.alter_column( | ||
"projects_tags", "project_id", existing_type=sa.BIGINT(), nullable=True | ||
) | ||
op.drop_constraint( | ||
"study_tags_study_id_tag_id_key", "projects_tags", type_="unique" | ||
) | ||
op.create_unique_constraint( | ||
"project_tags_project_uuid_unique", | ||
"projects_tags", | ||
["project_uuid_for_rut", "tag_id"], | ||
) | ||
op.drop_constraint("study_tags_study_id_fkey", "projects_tags", type_="foreignkey") | ||
op.create_foreign_key( | ||
"project_tags_project_id_fkey", | ||
"projects_tags", | ||
"projects", | ||
["project_id"], | ||
["id"], | ||
onupdate="CASCADE", | ||
ondelete="SET NULL", | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint( | ||
"project_tags_project_id_fkey", "projects_tags", type_="foreignkey" | ||
) | ||
op.create_foreign_key( | ||
"study_tags_study_id_fkey", | ||
"projects_tags", | ||
"projects", | ||
["project_id"], | ||
["id"], | ||
onupdate="CASCADE", | ||
ondelete="CASCADE", | ||
) | ||
op.drop_constraint( | ||
"project_tags_project_uuid_unique", "projects_tags", type_="unique" | ||
) | ||
op.create_unique_constraint( | ||
"study_tags_study_id_tag_id_key", "projects_tags", ["project_id", "tag_id"] | ||
) | ||
op.alter_column( | ||
"projects_tags", "project_id", existing_type=sa.BIGINT(), nullable=False | ||
) | ||
op.drop_column("projects_tags", "project_uuid_for_rut") | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.