-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unique constraints and new fixes (#1368)
This pull request adds unique constraints to the database tables and includes new fixes for the codebase.
- Loading branch information
Showing
3 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "langflow" | ||
version = "0.6.5a9" | ||
version = "0.6.5a10" | ||
description = "A Python package with a built-in web application" | ||
authors = ["Logspace <[email protected]>"] | ||
maintainers = [ | ||
|
59 changes: 59 additions & 0 deletions
59
src/backend/langflow/alembic/versions/b2fa308044b5_add_unique_constraints.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ### |
50 changes: 50 additions & 0 deletions
50
src/backend/langflow/alembic/versions/bc2f01c40e4a_new_fixes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ### |