Add primary key and unique constraints to user, apikey, and flow tables (#1347)
This pull request adds primary key and unique constraints to the user, apikey, and flow tables in the database schema. This ensures data integrity and improves database performance.
This commit is contained in:
commit
bc4cab16df
5 changed files with 15 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "langflow"
|
name = "langflow"
|
||||||
version = "0.6.5a5"
|
version = "0.6.5a6"
|
||||||
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 = [
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,8 @@ def upgrade() -> None:
|
||||||
sa.Column("create_at", sa.DateTime(), nullable=False),
|
sa.Column("create_at", sa.DateTime(), nullable=False),
|
||||||
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
||||||
sa.Column("last_login_at", sa.DateTime(), nullable=True),
|
sa.Column("last_login_at", sa.DateTime(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint("id"),
|
sa.PrimaryKeyConstraint("id", name="pk_user"),
|
||||||
sa.UniqueConstraint("id"),
|
sa.UniqueConstraint("id", name="uq_user_id"),
|
||||||
)
|
)
|
||||||
with op.batch_alter_table("user", schema=None) as batch_op:
|
with op.batch_alter_table("user", schema=None) as batch_op:
|
||||||
batch_op.create_index(
|
batch_op.create_index(
|
||||||
|
|
@ -83,8 +83,8 @@ def upgrade() -> None:
|
||||||
["user_id"],
|
["user_id"],
|
||||||
["user.id"],
|
["user.id"],
|
||||||
),
|
),
|
||||||
sa.PrimaryKeyConstraint("id"),
|
sa.PrimaryKeyConstraint("id", name="pk_apikey"),
|
||||||
sa.UniqueConstraint("id"),
|
sa.UniqueConstraint("id", name="uq_apikey_id"),
|
||||||
)
|
)
|
||||||
with op.batch_alter_table("apikey", schema=None) as batch_op:
|
with op.batch_alter_table("apikey", schema=None) as batch_op:
|
||||||
batch_op.create_index(
|
batch_op.create_index(
|
||||||
|
|
@ -106,8 +106,8 @@ def upgrade() -> None:
|
||||||
["user_id"],
|
["user_id"],
|
||||||
["user.id"],
|
["user.id"],
|
||||||
),
|
),
|
||||||
sa.PrimaryKeyConstraint("id"),
|
sa.PrimaryKeyConstraint("id", name="pk_flow"),
|
||||||
sa.UniqueConstraint("id"),
|
sa.UniqueConstraint("id", name="uq_flow_id"),
|
||||||
)
|
)
|
||||||
# Conditionally create indices for 'flow' table
|
# Conditionally create indices for 'flow' table
|
||||||
# if _alembic_tmp_flow exists, then we need to drop it first
|
# if _alembic_tmp_flow exists, then we need to drop it first
|
||||||
|
|
@ -145,7 +145,7 @@ def upgrade() -> None:
|
||||||
def downgrade() -> None:
|
def downgrade() -> None:
|
||||||
# ### commands auto generated by Alembic - please adjust! ###
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
|
||||||
conn = op.get_bind()
|
conn = op.get_bind()
|
||||||
inspector = Inspector.from_engine(conn) # type: ignore
|
inspector = Inspector.from_engine(conn) # type: ignore
|
||||||
# List existing tables
|
# List existing tables
|
||||||
existing_tables = inspector.get_table_names()
|
existing_tables = inspector.get_table_names()
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ def upgrade() -> None:
|
||||||
sa.Column('id', sqlmodel.sql.sqltypes.GUID(), nullable=False),
|
sa.Column('id', sqlmodel.sql.sqltypes.GUID(), nullable=False),
|
||||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||||
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
sa.Column('updated_at', sa.DateTime(), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_credential')),
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,8 @@ def downgrade() -> None:
|
||||||
sa.Column('flow_id', sa.CHAR(length=32), nullable=True),
|
sa.Column('flow_id', sa.CHAR(length=32), nullable=True),
|
||||||
sa.Column('id', sa.CHAR(length=32), nullable=False),
|
sa.Column('id', sa.CHAR(length=32), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['flow_id'], ['flow.id'], ),
|
sa.ForeignKeyConstraint(['flow_id'], ['flow.id'], ),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_flowstyle'))
|
||||||
sa.UniqueConstraint('id')
|
sa.UniqueConstraint('id', name=op.f('uq_flowstyle_id'))
|
||||||
)
|
)
|
||||||
op.create_table('component',
|
op.create_table('component',
|
||||||
sa.Column('id', sa.CHAR(length=32), nullable=False),
|
sa.Column('id', sa.CHAR(length=32), nullable=False),
|
||||||
|
|
@ -81,7 +81,7 @@ def downgrade() -> None:
|
||||||
sa.Column('is_read_only', sa.BOOLEAN(), nullable=False),
|
sa.Column('is_read_only', sa.BOOLEAN(), nullable=False),
|
||||||
sa.Column('create_at', sa.DATETIME(), nullable=False),
|
sa.Column('create_at', sa.DATETIME(), nullable=False),
|
||||||
sa.Column('update_at', sa.DATETIME(), nullable=False),
|
sa.Column('update_at', sa.DATETIME(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_component'))
|
||||||
)
|
)
|
||||||
|
|
||||||
with op.batch_alter_table('component', schema=None) as batch_op:
|
with op.batch_alter_table('component', schema=None) as batch_op:
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ def downgrade() -> None:
|
||||||
sa.Column("is_read_only", sa.BOOLEAN(), nullable=False),
|
sa.Column("is_read_only", sa.BOOLEAN(), nullable=False),
|
||||||
sa.Column("create_at", sa.DATETIME(), nullable=False),
|
sa.Column("create_at", sa.DATETIME(), nullable=False),
|
||||||
sa.Column("update_at", sa.DATETIME(), nullable=False),
|
sa.Column("update_at", sa.DATETIME(), nullable=False),
|
||||||
sa.PrimaryKeyConstraint("id"),
|
sa.PrimaryKeyConstraint("id", name="pk_component"),
|
||||||
)
|
)
|
||||||
with op.batch_alter_table("component", schema=None) as batch_op:
|
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_name", ["name"], unique=False)
|
||||||
|
|
@ -78,8 +78,8 @@ def downgrade() -> None:
|
||||||
["flow_id"],
|
["flow_id"],
|
||||||
["flow.id"],
|
["flow.id"],
|
||||||
),
|
),
|
||||||
sa.PrimaryKeyConstraint("id"),
|
sa.PrimaryKeyConstraint("id", name="pk_flowstyle"),
|
||||||
sa.UniqueConstraint("id"),
|
sa.UniqueConstraint("id", name="uq_flowstyle_id"),
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue