Skip to content

Commit 55b756d

Browse files
committed
Add indices for foreign keys
1 parent dbc93d5 commit 55b756d

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
defmodule Keila.Repo.Migrations.AddFkIndices do
2+
use Ecto.Migration
3+
4+
def change do
5+
create index(:accounts, :group_id)
6+
create index(:accounts_credit_transactions, :account_id)
7+
create index(:groups, :parent_id)
8+
create index(:user_groups, :user_id)
9+
create index(:user_groups, :group_id)
10+
create index(:user_group_roles, :user_group_id)
11+
create index(:user_group_roles, :role_id)
12+
create index(:roles, :parent_id)
13+
create index(:role_permissions, :role_id)
14+
create index(:role_permissions, :permission_id)
15+
create index(:tokens, :user_id)
16+
17+
create index(:contacts, :project_id)
18+
create index(:contacts_forms, :project_id)
19+
create index(:contacts_forms, :sender_id)
20+
create index(:contacts_forms, :template_id)
21+
22+
create index(:contacts_form_params, :form_id)
23+
24+
create index(:contacts_segments, :project_id)
25+
create index(:files, :project_id)
26+
27+
create index(:mailings_campaigns, :project_id)
28+
create index(:mailings_campaigns, :sender_id)
29+
create index(:mailings_campaigns, :template_id)
30+
create index(:mailings_campaigns, :segment_id)
31+
32+
create index(:mailings_recipients, :campaign_id)
33+
create index(:mailings_recipients, :contact_id)
34+
create index(:mailings_recipients, :queued_at, where: "queued_at is NULL")
35+
36+
create index(:mailings_senders, :project_id)
37+
create index(:mailings_senders, :shared_sender_id)
38+
39+
create index(:projects, :group_id)
40+
41+
create index(:templates, :project_id)
42+
43+
create index(:tracking_clicks, :link_id)
44+
create index(:tracking_clicks, :recipient_id)
45+
46+
create index(:tracking_links, :campaign_id)
47+
48+
create index(:contacts_events, :recipient_id)
49+
end
50+
end

0 commit comments

Comments
 (0)