|
| 1 | +defmodule ErrorTracker.Migration.MySQL.V03 do |
| 2 | + @moduledoc false |
| 3 | + |
| 4 | + use Ecto.Migration |
| 5 | + |
| 6 | + def up(_opts) do |
| 7 | + create table(:error_tracker_meta, primary_key: [name: :key, type: :string]) do |
| 8 | + add :value, :string, null: false |
| 9 | + end |
| 10 | + |
| 11 | + create table(:error_tracker_errors, primary_key: [name: :id, type: :bigserial]) do |
| 12 | + add :kind, :string, null: false |
| 13 | + add :reason, :text, null: false |
| 14 | + add :source_line, :text, null: false |
| 15 | + add :source_function, :text, null: false |
| 16 | + add :status, :string, null: false |
| 17 | + add :fingerprint, :string, null: false |
| 18 | + add :last_occurrence_at, :utc_datetime_usec, null: false |
| 19 | + |
| 20 | + timestamps(type: :utc_datetime_usec) |
| 21 | + end |
| 22 | + |
| 23 | + create unique_index(:error_tracker_errors, [:fingerprint]) |
| 24 | + |
| 25 | + create table(:error_tracker_occurrences, primary_key: [name: :id, type: :bigserial]) do |
| 26 | + add :context, :map, null: false |
| 27 | + add :reason, :text, null: false |
| 28 | + add :stacktrace, :map, null: false |
| 29 | + |
| 30 | + add :error_id, |
| 31 | + references(:error_tracker_errors, on_delete: :delete_all, column: :id, type: :bigserial), |
| 32 | + null: false |
| 33 | + |
| 34 | + timestamps(type: :utc_datetime_usec, updated_at: false) |
| 35 | + end |
| 36 | + |
| 37 | + create index(:error_tracker_occurrences, [:error_id]) |
| 38 | + |
| 39 | + create index(:error_tracker_errors, [:last_occurrence_at]) |
| 40 | + end |
| 41 | + |
| 42 | + def down(_opts) do |
| 43 | + drop table(:error_tracker_occurrences) |
| 44 | + drop table(:error_tracker_errors) |
| 45 | + drop table(:error_tracker_meta) |
| 46 | + end |
| 47 | +end |
0 commit comments