Add unique constraints and new fixes (#1368)
This pull request adds unique constraints to the database tables and includes new fixes for the codebase.
This commit is contained in:
commit
fc7bcf53c9
3 changed files with 110 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "langflow"
|
name = "langflow"
|
||||||
version = "0.6.5a9"
|
version = "0.6.5a10"
|
||||||
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 = [
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
"""Add unique constraints
|
||||||
|
|
||||||
|
Revision ID: b2fa308044b5
|
||||||
|
Revises: 0b8757876a7c
|
||||||
|
Create Date: 2024-01-26 13:31:14.797548
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
import sqlmodel
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = 'b2fa308044b5'
|
||||||
|
down_revision: Union[str, None] = '0b8757876a7c'
|
||||||
|
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('flow', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('is_component', sa.Boolean(), nullable=True))
|
||||||
|
batch_op.add_column(sa.Column('updated_at', sa.DateTime(), nullable=True))
|
||||||
|
batch_op.add_column(sa.Column('folder', sqlmodel.sql.sqltypes.AutoString(), nullable=True))
|
||||||
|
batch_op.add_column(sa.Column('user_id', sqlmodel.sql.sqltypes.GUID(), nullable=True))
|
||||||
|
batch_op.create_index(batch_op.f('ix_flow_user_id'), ['user_id'], unique=False)
|
||||||
|
batch_op.create_foreign_key(None, 'user', ['user_id'], ['id'])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
try:
|
||||||
|
with op.batch_alter_table('flow', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint(None, type_='foreignkey')
|
||||||
|
batch_op.drop_index(batch_op.f('ix_flow_user_id'))
|
||||||
|
batch_op.drop_column('user_id')
|
||||||
|
batch_op.drop_column('folder')
|
||||||
|
batch_op.drop_column('updated_at')
|
||||||
|
batch_op.drop_column('is_component')
|
||||||
|
|
||||||
|
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 ###
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
"""New fixes
|
||||||
|
|
||||||
|
Revision ID: bc2f01c40e4a
|
||||||
|
Revises: b2fa308044b5
|
||||||
|
Create Date: 2024-01-26 13:34:14.496769
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import Sequence, Union
|
||||||
|
|
||||||
|
import sqlalchemy as sa
|
||||||
|
import sqlmodel
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision: str = 'bc2f01c40e4a'
|
||||||
|
down_revision: Union[str, None] = 'b2fa308044b5'
|
||||||
|
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:
|
||||||
|
with op.batch_alter_table('flow', schema=None) as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('is_component', sa.Boolean(), nullable=True))
|
||||||
|
batch_op.add_column(sa.Column('updated_at', sa.DateTime(), nullable=True))
|
||||||
|
batch_op.add_column(sa.Column('folder', sqlmodel.sql.sqltypes.AutoString(), nullable=True))
|
||||||
|
batch_op.add_column(sa.Column('user_id', sqlmodel.sql.sqltypes.GUID(), nullable=True))
|
||||||
|
batch_op.create_index(batch_op.f('ix_flow_user_id'), ['user_id'], unique=False)
|
||||||
|
batch_op.create_foreign_key('flow_user_id_fkey'
|
||||||
|
, 'user', ['user_id'], ['id'])
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
try:
|
||||||
|
with op.batch_alter_table('flow', schema=None) as batch_op:
|
||||||
|
batch_op.drop_constraint('flow_user_id_fkey', type_='foreignkey')
|
||||||
|
batch_op.drop_index(batch_op.f('ix_flow_user_id'))
|
||||||
|
batch_op.drop_column('user_id')
|
||||||
|
batch_op.drop_column('folder')
|
||||||
|
batch_op.drop_column('updated_at')
|
||||||
|
batch_op.drop_column('is_component')
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
Loading…
Add table
Add a link
Reference in a new issue