-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(agents-api): Add migration for adding description to the tools r…
…elation Signed-off-by: Diwank Singh Tomer <[email protected]>
- Loading branch information
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
agents-api/migrations/migrate_1727922523_add_description_to_tools.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,64 @@ | ||
#/usr/bin/env python3 | ||
|
||
MIGRATION_ID = "add_description_to_tools" | ||
CREATED_AT = 1727922523.283493 | ||
|
||
|
||
add_description_to_tools = dict( | ||
up=""" | ||
?[agent_id, tool_id, type, name, description, spec, updated_at, created_at] := *tools { | ||
agent_id, tool_id, type, name, spec, updated_at, created_at | ||
}, description = null | ||
:replace tools { | ||
agent_id: Uuid, | ||
tool_id: Uuid, | ||
=> | ||
type: String, | ||
name: String, | ||
description: String?, | ||
spec: Json, | ||
updated_at: Float default now(), | ||
created_at: Float default now(), | ||
} | ||
""", | ||
down=""" | ||
?[agent_id, tool_id, type, name, spec, updated_at, created_at] := *tools { | ||
agent_id, tool_id, type, name, spec, updated_at, created_at | ||
} | ||
:replace tools { | ||
agent_id: Uuid, | ||
tool_id: Uuid, | ||
=> | ||
type: String, | ||
name: String, | ||
spec: Json, | ||
updated_at: Float default now(), | ||
created_at: Float default now(), | ||
} | ||
""", | ||
) | ||
|
||
|
||
queries_to_run = [ | ||
add_description_to_tools, | ||
] | ||
|
||
|
||
def run(client, *queries): | ||
joiner = "}\n\n{" | ||
|
||
query = joiner.join(queries) | ||
query = f"{{\n{query}\n}}" | ||
client.run(query) | ||
|
||
|
||
def up(client): | ||
run(client, *[q["up"] for q in queries_to_run]) | ||
|
||
|
||
def down(client): | ||
run(client, *[q["down"] for q in reversed(queries_to_run)]) |