Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
c8fb619d
Unverified
Commit
c8fb619d
authored
Jan 24, 2024
by
Yeuoly
Committed by
GitHub
Jan 24, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add tool index (#2152)
parent
57024614
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
dfb3b7f477da_add_tool_index.py
api/migrations/versions/dfb3b7f477da_add_tool_index.py
+38
-0
tools.py
api/models/tools.py
+3
-0
No files found.
api/migrations/versions/dfb3b7f477da_add_tool_index.py
0 → 100644
View file @
c8fb619d
"""add-tool-index
Revision ID: dfb3b7f477da
Revises: b24be59fbb04
Create Date: 2024-01-24 02:17:01.631635
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
'dfb3b7f477da'
down_revision
=
'b24be59fbb04'
branch_labels
=
None
depends_on
=
None
def
upgrade
():
# ### commands auto generated by Alembic - please adjust! ###
with
op
.
batch_alter_table
(
'tool_api_providers'
,
schema
=
None
)
as
batch_op
:
batch_op
.
create_unique_constraint
(
'unique_api_tool_provider'
,
[
'name'
,
'tenant_id'
])
with
op
.
batch_alter_table
(
'tool_files'
,
schema
=
None
)
as
batch_op
:
batch_op
.
create_index
(
'tool_file_conversation_id_idx'
,
[
'conversation_id'
],
unique
=
False
)
# ### end Alembic commands ###
def
downgrade
():
# ### commands auto generated by Alembic - please adjust! ###
with
op
.
batch_alter_table
(
'tool_files'
,
schema
=
None
)
as
batch_op
:
batch_op
.
drop_index
(
'tool_file_conversation_id_idx'
)
with
op
.
batch_alter_table
(
'tool_api_providers'
,
schema
=
None
)
as
batch_op
:
batch_op
.
drop_constraint
(
'unique_api_tool_provider'
,
type_
=
'unique'
)
# ### end Alembic commands ###
api/models/tools.py
View file @
c8fb619d
...
...
@@ -87,6 +87,7 @@ class ApiToolProvider(db.Model):
__tablename__
=
'tool_api_providers'
__table_args__
=
(
db
.
PrimaryKeyConstraint
(
'id'
,
name
=
'tool_api_provider_pkey'
),
db
.
UniqueConstraint
(
'name'
,
'tenant_id'
,
name
=
'unique_api_tool_provider'
)
)
id
=
db
.
Column
(
UUID
,
server_default
=
db
.
text
(
'uuid_generate_v4()'
))
...
...
@@ -210,6 +211,8 @@ class ToolFile(db.Model):
__tablename__
=
"tool_files"
__table_args__
=
(
db
.
PrimaryKeyConstraint
(
'id'
,
name
=
'tool_file_pkey'
),
# add index for conversation_id
db
.
Index
(
'tool_file_conversation_id_idx'
,
'conversation_id'
),
)
id
=
db
.
Column
(
UUID
,
server_default
=
db
.
text
(
'uuid_generate_v4()'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment