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.
🎨 introducing parent ids to rut (🗃️) (ITISFoundation#5891)
- Loading branch information
1 parent
b169cc8
commit 88e23a6
Showing
15 changed files
with
224 additions
and
19 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
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
120 changes: 120 additions & 0 deletions
120
...src/simcore_postgres_database/migration/versions/481d5b472721_add_parent_fields_to_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,120 @@ | ||
"""add_parent_fields_to_rut | ||
Revision ID: 481d5b472721 | ||
Revises: 0d85bd35bdaa | ||
Create Date: 2024-06-03 08:58:35.086686+00:00 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "481d5b472721" | ||
down_revision = "0d85bd35bdaa" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column( | ||
"resource_tracker_service_runs", | ||
sa.Column("parent_project_id", sa.String(), nullable=True), | ||
) | ||
op.add_column( | ||
"resource_tracker_service_runs", | ||
sa.Column("root_parent_project_id", sa.String(), nullable=True), | ||
) | ||
op.add_column( | ||
"resource_tracker_service_runs", | ||
sa.Column("root_parent_project_name", sa.String(), nullable=True), | ||
) | ||
op.add_column( | ||
"resource_tracker_service_runs", | ||
sa.Column("parent_node_id", sa.String(), nullable=True), | ||
) | ||
op.add_column( | ||
"resource_tracker_service_runs", | ||
sa.Column("root_parent_node_id", sa.String(), nullable=True), | ||
) | ||
|
||
# Populate new columns with values from the existing column | ||
op.execute( | ||
sa.DDL( | ||
f""" | ||
UPDATE resource_tracker_service_runs | ||
SET parent_project_id = project_id, | ||
root_parent_project_id = project_id, | ||
root_parent_project_name = project_name, | ||
parent_node_id = node_id, | ||
root_parent_node_id = node_id | ||
""" | ||
) | ||
) | ||
|
||
# Make newly created column non-nullable | ||
op.alter_column( | ||
"resource_tracker_service_runs", | ||
"parent_project_id", | ||
nullable=False, | ||
) | ||
op.alter_column( | ||
"resource_tracker_service_runs", | ||
"root_parent_project_id", | ||
nullable=False, | ||
) | ||
op.alter_column( | ||
"resource_tracker_service_runs", | ||
"root_parent_project_name", | ||
nullable=False, | ||
) | ||
op.alter_column( | ||
"resource_tracker_service_runs", | ||
"parent_node_id", | ||
nullable=False, | ||
) | ||
op.alter_column( | ||
"resource_tracker_service_runs", | ||
"root_parent_node_id", | ||
nullable=False, | ||
) | ||
|
||
# Make already existing columns non-nullable | ||
op.alter_column( | ||
"resource_tracker_service_runs", | ||
"project_name", | ||
existing_type=sa.VARCHAR(), | ||
nullable=False, | ||
) | ||
op.alter_column( | ||
"resource_tracker_service_runs", | ||
"node_name", | ||
existing_type=sa.VARCHAR(), | ||
nullable=False, | ||
) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.alter_column( | ||
"resource_tracker_service_runs", | ||
"node_name", | ||
existing_type=sa.VARCHAR(), | ||
nullable=True, | ||
) | ||
op.alter_column( | ||
"resource_tracker_service_runs", | ||
"project_name", | ||
existing_type=sa.VARCHAR(), | ||
nullable=True, | ||
) | ||
op.drop_column("resource_tracker_service_runs", "root_parent_node_id") | ||
op.drop_column("resource_tracker_service_runs", "parent_node_id") | ||
op.drop_column("resource_tracker_service_runs", "root_parent_project_name") | ||
op.drop_column("resource_tracker_service_runs", "root_parent_project_id") | ||
op.drop_column("resource_tracker_service_runs", "parent_project_id") | ||
# ### 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
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.