🔧 chore(alembic): change columns to be nullable in migration script
🔧 chore(api_key.py): make last_used_at field nullable in ApiKeyBase model 🔧 chore(flow.py): make data field nullable in FlowBase model 🔧 chore(user.py): make profile_image field nullable in User model
This commit is contained in:
parent
d17d127b81
commit
a6b30e1b8b
4 changed files with 84 additions and 3 deletions
|
|
@ -0,0 +1,80 @@
|
||||||
|
"""Change columns to be nullable
|
||||||
|
|
||||||
|
Revision ID: eb5866d51fd2
|
||||||
|
Revises: 67cc006d50bf
|
||||||
|
Create Date: 2023-10-04 10:18:25.640458
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
import sqlmodel
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = "eb5866d51fd2"
|
||||||
|
down_revision: Union[str, None] = "67cc006d50bf"
|
||||||
|
branch_labels: Union[str, Sequence[str], None] = None
|
||||||
|
depends_on: Union[str, Sequence[str], None] = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
try:
|
||||||
|
op.drop_table("flowstyle")
|
||||||
|
with op.batch_alter_table("component", schema=None) as batch_op:
|
||||||
|
batch_op.drop_index("ix_component_frontend_node_id")
|
||||||
|
batch_op.drop_index("ix_component_name")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
op.drop_table("component")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
try:
|
||||||
|
op.create_table(
|
||||||
|
"component",
|
||||||
|
sa.Column("id", sa.CHAR(length=32), nullable=False),
|
||||||
|
sa.Column("frontend_node_id", sa.CHAR(length=32), nullable=False),
|
||||||
|
sa.Column("name", sa.VARCHAR(), nullable=False),
|
||||||
|
sa.Column("description", sa.VARCHAR(), nullable=True),
|
||||||
|
sa.Column("python_code", sa.VARCHAR(), nullable=True),
|
||||||
|
sa.Column("return_type", sa.VARCHAR(), nullable=True),
|
||||||
|
sa.Column("is_disabled", sa.BOOLEAN(), nullable=False),
|
||||||
|
sa.Column("is_read_only", sa.BOOLEAN(), nullable=False),
|
||||||
|
sa.Column("create_at", sa.DATETIME(), nullable=False),
|
||||||
|
sa.Column("update_at", sa.DATETIME(), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint("id"),
|
||||||
|
)
|
||||||
|
with op.batch_alter_table("component", schema=None) as batch_op:
|
||||||
|
batch_op.create_index("ix_component_name", ["name"], unique=False)
|
||||||
|
batch_op.create_index(
|
||||||
|
"ix_component_frontend_node_id", ["frontend_node_id"], unique=False
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
op.create_table(
|
||||||
|
"flowstyle",
|
||||||
|
sa.Column("color", sa.VARCHAR(), nullable=False),
|
||||||
|
sa.Column("emoji", sa.VARCHAR(), nullable=False),
|
||||||
|
sa.Column("flow_id", sa.CHAR(length=32), nullable=True),
|
||||||
|
sa.Column("id", sa.CHAR(length=32), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(
|
||||||
|
["flow_id"],
|
||||||
|
["flow.id"],
|
||||||
|
),
|
||||||
|
sa.PrimaryKeyConstraint("id"),
|
||||||
|
sa.UniqueConstraint("id"),
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
@ -12,7 +12,7 @@ if TYPE_CHECKING:
|
||||||
class ApiKeyBase(SQLModelSerializable):
|
class ApiKeyBase(SQLModelSerializable):
|
||||||
name: Optional[str] = Field(index=True)
|
name: Optional[str] = Field(index=True)
|
||||||
created_at: datetime = Field(default_factory=datetime.utcnow)
|
created_at: datetime = Field(default_factory=datetime.utcnow)
|
||||||
last_used_at: Optional[datetime] = Field(default=None)
|
last_used_at: Optional[datetime] = Field(default=None, nullable=True)
|
||||||
total_uses: int = Field(default=0)
|
total_uses: int = Field(default=0)
|
||||||
is_active: bool = Field(default=True)
|
is_active: bool = Field(default=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from langflow.services.database.models.base import SQLModelSerializable
|
from langflow.services.database.models.base import SQLModelSerializable
|
||||||
from pydantic import validator
|
from pydantic import validator
|
||||||
|
|
||||||
from sqlmodel import Field, JSON, Column, Relationship
|
from sqlmodel import Field, JSON, Column, Relationship
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
from typing import Dict, Optional, TYPE_CHECKING
|
from typing import Dict, Optional, TYPE_CHECKING
|
||||||
|
|
@ -13,7 +14,7 @@ if TYPE_CHECKING:
|
||||||
class FlowBase(SQLModelSerializable):
|
class FlowBase(SQLModelSerializable):
|
||||||
name: str = Field(index=True)
|
name: str = Field(index=True)
|
||||||
description: Optional[str] = Field(index=True)
|
description: Optional[str] = Field(index=True)
|
||||||
data: Optional[Dict] = Field(default=None)
|
data: Optional[Dict] = Field(default=None, nullable=True)
|
||||||
|
|
||||||
@validator("data")
|
@validator("data")
|
||||||
def validate_json(v):
|
def validate_json(v):
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class User(SQLModelSerializable, table=True):
|
||||||
id: UUID = Field(default_factory=uuid4, primary_key=True, unique=True)
|
id: UUID = Field(default_factory=uuid4, primary_key=True, unique=True)
|
||||||
username: str = Field(index=True, unique=True)
|
username: str = Field(index=True, unique=True)
|
||||||
password: str = Field()
|
password: str = Field()
|
||||||
profile_image: Optional[str] = Field(default=None)
|
profile_image: Optional[str] = Field(default=None, nullable=True)
|
||||||
is_active: bool = Field(default=False)
|
is_active: bool = Field(default=False)
|
||||||
is_superuser: bool = Field(default=False)
|
is_superuser: bool = Field(default=False)
|
||||||
create_at: datetime = Field(default_factory=datetime.utcnow)
|
create_at: datetime = Field(default_factory=datetime.utcnow)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue