Update nullable attribute for created_at field in variable table (#1697)

* Update nullable attribute for created_at field in variable table

* Update package versions in pyproject.toml and poetry.lock files
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-04-13 11:23:42 -03:00 • committed by GitHub
commit 05104117ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 126 additions and 116 deletions

View file

@ -0,0 +1,66 @@
"""Modify nullable
Revision ID: 58b28437a398
Revises: 4e5980a44eaa
Create Date: 2024-04-13 10:57:23.061709
"""
from typing import Sequence, Union
import sqlalchemy as sa
from alembic import op
from loguru import logger
from sqlalchemy.engine.reflection import Inspector
down_revision: Union[str, None] = "4e5980a44eaa"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
# Revision identifiers, used by Alembic.
revision = "58b28437a398"
down_revision = "4e5980a44eaa"
branch_labels = None
depends_on = None
def upgrade():
conn = op.get_bind()
inspector = Inspector.from_engine(conn)
tables = ["apikey", "variable"] # List of tables to modify
for table_name in tables:
modify_nullable(conn, inspector, table_name, upgrade=True)
def downgrade():
conn = op.get_bind()
inspector = Inspector.from_engine(conn)
tables = ["apikey", "variable"] # List of tables to revert
for table_name in tables:
modify_nullable(conn, inspector, table_name, upgrade=False)
def modify_nullable(conn, inspector, table_name, upgrade=True):
columns = inspector.get_columns(table_name)
nullable_changes = {"apikey": {"created_at": False}, "variable": {"created_at": True, "updated_at": True}}
if table_name in columns:
with op.batch_alter_table(table_name, schema=None) as batch_op:
for column_name, nullable_setting in nullable_changes.get(table_name, {}).items():
column_info = next((col for col in columns if col["name"] == column_name), None)
if column_info:
current_nullable = column_info["nullable"]
target_nullable = nullable_setting if upgrade else not nullable_setting
if current_nullable != target_nullable:
batch_op.alter_column(
column_name, existing_type=sa.DateTime(timezone=True), nullable=target_nullable
)
else:
logger.info(
f"Column '{column_name}' in table '{table_name}' already has nullable={target_nullable}"
)
else:
logger.warning(f"Column '{column_name}' not found in table '{table_name}'")

View file

@ -1146,13 +1146,13 @@ extended-testing = ["lxml (>=5.1.0,<6.0.0)"]
[[package]]
name = "langsmith"
version = "0.1.46"
version = "0.1.47"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
optional = false
python-versions = "<4.0,>=3.8.1"
files = [
{file = "langsmith-0.1.46-py3-none-any.whl", hash = "sha256:459b76b25fe3b86e7bf5521f4dc8c3f796de288ceb3e0d05c99db4d509edaabf"},
{file = "langsmith-0.1.46.tar.gz", hash = "sha256:a5a96259e411641633561575b567c2139bede997f7104eeedb59cb9511416d1b"},
{file = "langsmith-0.1.47-py3-none-any.whl", hash = "sha256:17b0a908b8d39b6da3ecff658c8c00304b0b62f59945a5e16c2da5a254ea21a6"},
{file = "langsmith-0.1.47.tar.gz", hash = "sha256:f5ddd17628baa03a775525c5547a543a559313e425cdb2bf23579ffcf6056a76"},
]
[package.dependencies]

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "langflow-base"
version = "0.0.33"
version = "0.0.34"
description = "A Python package with a built-in web application"
authors = ["Logspace <contact@logspace.ai>"]
maintainers = [