Add logger import and fix error handling during upgrade in alembic scripts (#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
This commit is contained in:
parent
2f6bb8d0e0
commit
fee39eeccb
6 changed files with 366 additions and 360 deletions
706
poetry.lock
generated
706
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -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 <contact@logspace.ai>"]
|
||||
maintainers = [
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 ###
|
||||
|
||||
|
|
@ -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 ###
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
@ -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 ###
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ from typing import Sequence, Union
|
|||
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.
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue