Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"funcapi_function_job_collections_access_rights",
sa.Column("product_name", sa.String(), nullable=False),
sa.Column("product_name", sa.String(), nullable=True),
)
op.create_foreign_key(
"fk_func_access_to_products_product_name",
Expand All @@ -33,7 +33,7 @@ def upgrade():
)
op.add_column(
"funcapi_function_jobs_access_rights",
sa.Column("product_name", sa.String(), nullable=False),
sa.Column("product_name", sa.String(), nullable=True),
)
op.create_foreign_key(
"fk_func_access_to_products_product_name",
Expand All @@ -46,7 +46,7 @@ def upgrade():
)
op.add_column(
"funcapi_functions_access_rights",
sa.Column("product_name", sa.String(), nullable=False),
sa.Column("product_name", sa.String(), nullable=True),
)
op.create_foreign_key(
"fk_func_access_to_products_product_name",
Expand All @@ -57,6 +57,49 @@ def upgrade():
onupdate="CASCADE",
ondelete="CASCADE",
)

# Backfill existing rows with "osparc"
op.execute(
"""
UPDATE funcapi_function_job_collections_access_rights
SET product_name = 'osparc'
WHERE product_name IS NULL
"""
)
op.execute(
"""
UPDATE funcapi_function_jobs_access_rights
SET product_name = 'osparc'
WHERE product_name IS NULL
"""
)
op.execute(
"""
UPDATE funcapi_functions_access_rights
SET product_name = 'osparc'
WHERE product_name IS NULL
"""
)

# Alter columns to set nullable=False
op.alter_column(
"funcapi_function_job_collections_access_rights",
"product_name",
existing_type=sa.String(),
nullable=False,
)
op.alter_column(
"funcapi_function_jobs_access_rights",
"product_name",
existing_type=sa.String(),
nullable=False,
)
op.alter_column(
"funcapi_functions_access_rights",
"product_name",
existing_type=sa.String(),
nullable=False,
)
# ### end Alembic commands ###


Expand Down
Loading