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]
|
[tool.poetry]
|
||||||
name = "langflow"
|
name = "langflow"
|
||||||
version = "0.6.13"
|
version = "0.6.14"
|
||||||
description = "A Python package with a built-in web application"
|
description = "A Python package with a built-in web application"
|
||||||
authors = ["Logspace <contact@logspace.ai>"]
|
authors = ["Logspace <contact@logspace.ai>"]
|
||||||
maintainers = [
|
maintainers = [
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ from alembic import op
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
import sqlmodel
|
import sqlmodel
|
||||||
from sqlalchemy.engine.reflection import Inspector
|
from sqlalchemy.engine.reflection import Inspector
|
||||||
|
from loguru import logger #noqa
|
||||||
${imports if imports else ""}
|
${imports if imports else ""}
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ def upgrade() -> None:
|
||||||
"name", existing_type=sqlmodel.sql.sqltypes.AutoString(), nullable=True
|
"name", existing_type=sqlmodel.sql.sqltypes.AutoString(), nullable=True
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logger.exception(f"Error during upgrade: {e}")
|
||||||
pass
|
pass
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
@ -38,5 +39,6 @@ def downgrade() -> None:
|
||||||
with op.batch_alter_table("apikey", schema=None) as batch_op:
|
with op.batch_alter_table("apikey", schema=None) as batch_op:
|
||||||
batch_op.alter_column("name", existing_type=sa.VARCHAR(), nullable=False)
|
batch_op.alter_column("name", existing_type=sa.VARCHAR(), nullable=False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logger.exception(f"Error during upgrade: {e}")
|
||||||
pass
|
pass
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ def upgrade() -> None:
|
||||||
sa.Column("is_component", sa.Boolean(), nullable=True)
|
sa.Column("is_component", sa.Boolean(), nullable=True)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logger.exception(f"Error during upgrade: {e}")
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
if "store_api_key" not in user_columns:
|
if "store_api_key" not in user_columns:
|
||||||
|
|
@ -41,6 +42,7 @@ def upgrade() -> None:
|
||||||
sa.Column("store_api_key", sqlmodel.AutoString(), nullable=True)
|
sa.Column("store_api_key", sqlmodel.AutoString(), nullable=True)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logger.exception(f"Error during upgrade: {e}")
|
||||||
pass
|
pass
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ from typing import Sequence, Union
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
import sqlmodel
|
import sqlmodel
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
from loguru import logger # noqa
|
||||||
from sqlalchemy.engine.reflection import Inspector
|
from sqlalchemy.engine.reflection import Inspector
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
|
|
@ -55,15 +56,13 @@ def upgrade() -> None:
|
||||||
batch_op.create_index(
|
batch_op.create_index(
|
||||||
batch_op.f("ix_flow_user_id"), ["user_id"], unique=False
|
batch_op.f("ix_flow_user_id"), ["user_id"], unique=False
|
||||||
)
|
)
|
||||||
if "fk_flow_user_id_user" not in indices_names:
|
fk_names = [fk["name"] for fk in inspector.get_foreign_keys("flow")]
|
||||||
batch_op.create_foreign_key(
|
if "fk_flow_user_id_user" not in fk_names:
|
||||||
"fk_flow_user_id_user", "user", ["user_id"], ["id"]
|
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
|
pass
|
||||||
# ### end Alembic commands ###
|
|
||||||
|
|
||||||
|
|
||||||
def downgrade() -> None:
|
def downgrade() -> None:
|
||||||
conn = op.get_bind()
|
conn = op.get_bind()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue