Skip to content

Commit 0781bb2

Browse files
committed
add new fields
1 parent 2aede37 commit 0781bb2

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
defmodule Algora.Repo.Migrations.CreateEmailsTable do
2+
use Ecto.Migration
3+
4+
def change do
5+
create table(:emails, primary_key: false) do
6+
add :id, :string, primary_key: true
7+
8+
# Essential email fields
9+
add :subject, :text, null: false
10+
add :sender, :string, null: false
11+
add :sender_email, :string, null: false
12+
add :to_recipients, :text
13+
add :cc_recipients, :text
14+
add :body, :text, null: false
15+
add :date, :utc_datetime, null: false
16+
add :gmail_id, :string, null: false
17+
add :message_id, :string, null: false
18+
add :thread_id, :string, null: false
19+
add :direction, :string, default: "incoming", null: false
20+
21+
timestamps()
22+
end
23+
24+
create unique_index(:emails, [:gmail_id])
25+
create index(:emails, [:thread_id])
26+
create index(:emails, [:date])
27+
create index(:emails, [:sender_email])
28+
create index(:emails, [:direction])
29+
end
30+
end
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
defmodule Algora.Repo.Migrations.CreateToolCallsTable do
2+
use Ecto.Migration
3+
4+
def change do
5+
create table(:tool_calls, primary_key: false) do
6+
add :id, :string, primary_key: true
7+
add :agent_type, :string, null: false
8+
add :tool_name, :string, null: false
9+
add :arguments, :map, null: false
10+
add :context, :map
11+
add :result, :text
12+
add :user_id, references(:users, type: :string, on_delete: :delete_all)
13+
add :email_id, references(:emails, type: :string, on_delete: :delete_all)
14+
add :executed_at, :utc_datetime_usec, null: false
15+
add :success, :boolean, null: false
16+
17+
timestamps(type: :utc_datetime_usec)
18+
end
19+
20+
create index(:tool_calls, [:user_id])
21+
create index(:tool_calls, [:email_id])
22+
create index(:tool_calls, [:agent_type])
23+
create index(:tool_calls, [:tool_name])
24+
create index(:tool_calls, [:executed_at])
25+
create index(:tool_calls, [:success])
26+
end
27+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule Algora.Repo.Migrations.AddSummaryToEmails do
2+
use Ecto.Migration
3+
4+
def change do
5+
alter table(:emails) do
6+
add :summary, :text
7+
end
8+
end
9+
end

0 commit comments

Comments
 (0)