diff --git a/packages/postgres-database/src/simcore_postgres_database/migration/versions/2a4b4167e088_product_name_column_in_api_keys_table.py b/packages/postgres-database/src/simcore_postgres_database/migration/versions/2a4b4167e088_product_name_column_in_api_keys_table.py index 7a407202e5f..657459fc3a5 100644 --- a/packages/postgres-database/src/simcore_postgres_database/migration/versions/2a4b4167e088_product_name_column_in_api_keys_table.py +++ b/packages/postgres-database/src/simcore_postgres_database/migration/versions/2a4b4167e088_product_name_column_in_api_keys_table.py @@ -24,7 +24,7 @@ def _find_default_product_name_or_none(conn): def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.add_column("api_keys", sa.Column("product_name", sa.String(), nullable=False)) + op.add_column("api_keys", sa.Column("product_name", sa.String(), nullable=True)) op.create_foreign_key( "fk_api_keys_product_name", "api_keys", @@ -39,7 +39,12 @@ def upgrade(): conn = op.get_bind() default_product = _find_default_product_name_or_none(conn) if default_product: - op.execute(f"UPDATE api_keys SET product_name = '{default_product}'") + op.execute(sa.DDL(f"UPDATE api_keys SET product_name = '{default_product}'")) + + # make it non nullable now + op.alter_column( + "api_keys", "product_name", existing_type=sa.String(), nullable=False + ) def downgrade():