Skip to content

Commit

Permalink
Fix unique constraints and column nullability (#1348)
Browse files Browse the repository at this point in the history
This pull request tries to fix the unique constraints and column nullability in the codebase.
  • Loading branch information
ogabrielluiz authored Jan 17, 2024
2 parents bc4cab1 + e4cbe9c commit 36a6a30
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langflow"
version = "0.6.5a6"
version = "0.6.5a7"
description = "A Python package with a built-in web application"
authors = ["Logspace <[email protected]>"]
maintainers = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def upgrade() -> None:

with op.batch_alter_table('user', schema=None) as batch_op:
batch_op.create_unique_constraint('uq_user_id', ['id'])
except Exception:
except Exception as e:
print(e)
pass

# ### end Alembic commands ###
Expand All @@ -44,6 +45,7 @@ def downgrade() -> None:

with op.batch_alter_table('apikey', schema=None) as batch_op:
batch_op.drop_constraint('uq_apikey_id', type_='unique')
except Exception:
except Exception as e:
print(e)
pass
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ def upgrade() -> None:
sa.Column('id', sqlmodel.sql.sqltypes.GUID(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('updated_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id', name=op.f('pk_credential')),
sa.PrimaryKeyConstraint('id'),
)
except Exception:
except Exception as e:
print(e)
pass
# ### end Alembic commands ###

Expand All @@ -40,6 +41,7 @@ def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
try:
op.drop_table('credential')
except Exception:
except Exception as e:
print(e)
pass
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def downgrade() -> None:

with op.batch_alter_table("flow", schema=None) as batch_op:
batch_op.drop_column("is_component")
except Exception:
except Exception as e:
print(e)
pass
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def upgrade() -> None:
with op.batch_alter_table('flow', schema=None) as batch_op:
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))

# ### end Alembic commands ###


Expand Down Expand Up @@ -67,8 +66,8 @@ def downgrade() -> None:
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', name=op.f('pk_flowstyle'))
sa.UniqueConstraint('id', name=op.f('uq_flowstyle_id'))
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('id')
)
op.create_table('component',
sa.Column('id', sa.CHAR(length=32), nullable=False),
Expand All @@ -81,7 +80,7 @@ def downgrade() -> None:
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', name=op.f('pk_component'))
sa.PrimaryKeyConstraint('id')
)

with op.batch_alter_table('component', schema=None) as batch_op:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ def upgrade() -> None:
except exc.SQLAlchemyError:
# connection.execute(text("ROLLBACK"))
pass
except Exception:
except Exception as e:
print(e)
pass

try:
op.drop_table("component")
except exc.SQLAlchemyError:
# connection.execute(text("ROLLBACK"))
pass
except Exception:
except Exception as e:
print(e)
pass
# ### end Alembic commands ###

Expand All @@ -64,7 +66,8 @@ def downgrade() -> None:
batch_op.create_index(
"ix_component_frontend_node_id", ["frontend_node_id"], unique=False
)
except Exception:
except Exception as e:
print(e)
pass

try:
Expand All @@ -81,6 +84,7 @@ def downgrade() -> None:
sa.PrimaryKeyConstraint("id", name="pk_flowstyle"),
sa.UniqueConstraint("id", name="uq_flowstyle_id"),
)
except Exception:
except Exception as e:
print(e)
pass
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "f5ee9749d1a6"
Expand All @@ -26,7 +24,8 @@ def upgrade() -> None:
batch_op.alter_column(
"user_id", existing_type=sa.CHAR(length=32), nullable=True
)
except Exception:
except Exception as e:
print(e)
pass

# ### end Alembic commands ###
Expand All @@ -39,7 +38,8 @@ def downgrade() -> None:
batch_op.alter_column(
"user_id", existing_type=sa.CHAR(length=32), nullable=False
)
except Exception:
except Exception as e:
print(e)
pass

# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def upgrade() -> None:
try:
with op.batch_alter_table('credential', schema=None) as batch_op:
batch_op.create_foreign_key("fk_credential_user_id", 'user', ['user_id'], ['id'])
except Exception:
except Exception as e:
print(e)
pass

# ### end Alembic commands ###
Expand All @@ -32,7 +33,8 @@ def downgrade() -> None:
try:
with op.batch_alter_table('credential', schema=None) as batch_op:
batch_op.drop_constraint("fk_credential_user_id", type_='foreignkey')
except Exception:
except Exception as e:
print(e)
pass

# ### end Alembic commands ###

0 comments on commit 36a6a30

Please sign in to comment.