forked from er-jpg/logger_psql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigration.exs.eex
42 lines (37 loc) · 1.74 KB
/
migration.exs.eex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
defmodule <%= module_prefix %>.Repo.Migrations.CreateLogTable do
use Ecto.Migration
def change do
<%= unless is_nil(db_prefix) or db_prefix == "" do %>
execute("CREATE SCHEMA IF NOT EXISTS <%= db_prefix %>")
<% end %>
create table(<%= inspect(schema_name) %>, primary_key: false<%= unless is_nil(db_prefix) or db_prefix == "", do: ", prefix: \"#{db_prefix}\"" %>) do
add :id, :binary_id, primary_key: true
add :customer_id, :integer
add :level, :string
add :application, :string
add :domain, :string
add :file, :string
add :function, :string
add :line, :string
add :module, :string
add :pid, :string
add :time, :utc_datetime
add :user_email, :string
add :user_id, :integer
add :device_id, :string
add :device_name, :string
add :marketing_version, :string
add :build_number, :string
add :system_version, :string
add :message, :text
add :metadata, :map
add :request_id, :string
timestamps()
end
create index(<%= inspect(schema_name) %>, [:customer_id]<%= unless is_nil(db_prefix) or db_prefix == "", do: ", prefix: \"#{db_prefix}\"" %>)
create index(<%= inspect(schema_name) %>, [:user_email]<%= unless is_nil(db_prefix) or db_prefix == "", do: ", prefix: \"#{db_prefix}\"" %>)
create index(<%= inspect(schema_name) %>, [:device_id]<%= unless is_nil(db_prefix) or db_prefix == "", do: ", prefix: \"#{db_prefix}\"" %>)
create index(<%= inspect(schema_name) %>, [:level]<%= unless is_nil(db_prefix) or db_prefix == "", do: ", prefix: \"#{db_prefix}\"" %>)
create index(<%= inspect(schema_name) %>, [:inserted_at]<%= unless is_nil(db_prefix) or db_prefix == "", do: ", prefix: \"#{db_prefix}\"" %>)
end
end