🐛 fix(alembic): change "user_id" column in "flow" table to be nullable to handle existing data without a user_id

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-25 16:31:24 -03:00
commit fc32ee63e1

View file

@ -37,7 +37,7 @@ def upgrade() -> None:
op.drop_column("apikey", "create_at")
with contextlib.suppress(sa.exc.OperationalError):
op.add_column(
"flow", sa.Column("user_id", sqlmodel.sql.sqltypes.GUID(), nullable=False)
"flow", sa.Column("user_id", sqlmodel.sql.sqltypes.GUID(), nullable=True)
)
op.create_index(op.f("ix_flow_user_id"), "flow", ["user_id"], unique=False)
op.create_foreign_key(None, "flow", "user", ["user_id"], ["id"])