Skip to content

Commit

Permalink
Add logger import and fix error handling during upgrade in alembic sc…
Browse files Browse the repository at this point in the history
…ripts (#1650)

* Add logger import in script.py.mako

* Fix error handling during upgrade in alembic scripts

* Bump version to 0.6.14 in pyproject.toml
  • Loading branch information
ogabrielluiz authored Apr 9, 2024
1 parent 2f6bb8d commit fee39ee
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 368 deletions.
722 changes: 362 additions & 360 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langflow"
version = "0.6.13"
version = "0.6.14"
description = "A Python package with a built-in web application"
authors = ["Logspace <[email protected]>"]
maintainers = [
Expand Down
1 change: 1 addition & 0 deletions src/backend/langflow/alembic/script.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ from alembic import op
import sqlalchemy as sa
import sqlmodel
from sqlalchemy.engine.reflection import Inspector
from loguru import logger #noqa
${imports if imports else ""}

# revision identifiers, used by Alembic.
Expand Down
2 changes: 2 additions & 0 deletions src/backend/langflow/alembic/versions/1ef9c4f3765d_.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def upgrade() -> None:
"name", existing_type=sqlmodel.sql.sqltypes.AutoString(), nullable=True
)
except Exception as e:
logger.exception(f"Error during upgrade: {e}")
pass
# ### end Alembic commands ###

Expand All @@ -38,5 +39,6 @@ def downgrade() -> None:
with op.batch_alter_table("apikey", schema=None) as batch_op:
batch_op.alter_column("name", existing_type=sa.VARCHAR(), nullable=False)
except Exception as e:
logger.exception(f"Error during upgrade: {e}")
pass
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def upgrade() -> None:
sa.Column("is_component", sa.Boolean(), nullable=True)
)
except Exception as e:
logger.exception(f"Error during upgrade: {e}")
pass
try:
if "store_api_key" not in user_columns:
Expand All @@ -41,6 +42,7 @@ def upgrade() -> None:
sa.Column("store_api_key", sqlmodel.AutoString(), nullable=True)
)
except Exception as e:
logger.exception(f"Error during upgrade: {e}")
pass
# ### end Alembic commands ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import sqlalchemy as sa
import sqlmodel
from alembic import op
from loguru import logger # noqa
from sqlalchemy.engine.reflection import Inspector

# revision identifiers, used by Alembic.
Expand Down Expand Up @@ -55,15 +56,13 @@ def upgrade() -> None:
batch_op.create_index(
batch_op.f("ix_flow_user_id"), ["user_id"], unique=False
)
if "fk_flow_user_id_user" not in indices_names:
batch_op.create_foreign_key(
"fk_flow_user_id_user", "user", ["user_id"], ["id"]
)
fk_names = [fk["name"] for fk in inspector.get_foreign_keys("flow")]
if "fk_flow_user_id_user" not in fk_names:
batch_op.create_foreign_key("fk_flow_user_id_user", "user", ["user_id"], ["id"])

except Exception:
except Exception as e:
logger.exception(f"Error during upgrade: {e}")
pass
# ### end Alembic commands ###


def downgrade() -> None:
conn = op.get_bind()
Expand Down

0 comments on commit fee39ee

Please sign in to comment.