defmodule GitGud.Repo.Migrations.CreateAuditEntries do
use Ecto.Migration
# Append-only record of who changed what in an organization, a
# repository or the instance (`GitGud.Audit`). Every reference is
# nilified rather than cascaded, and each carries a snapshot label, so
# an entry outlives what it's about.
def change do
create table(:audit_entries) do
add :action, :string, null: false
add :category, :string, null: false
add :actor_type, :string, null: false
add :actor_id, references(:users, on_delete: :nilify_all)
add :actor_ref, :bigint
add :actor_label, :string, null: false
add :via, :string
add :organization_id, references(:organizations, on_delete: :nilify_all)
add :organization_label, :string
add :repository_id, references(:repositories, on_delete: :nilify_all)
add :repository_label, :string
add :target_type, :string
add :target_id, :bigint
add :target_label, :string
add :subject_user_id, references(:users, on_delete: :nilify_all)
add :metadata, :map, null: false, default: %{}
add :ip, :string
add :user_agent, :string, size: 512
add :inserted_at, :utc_datetime_usec, null: false, default: fragment("now()")
end
create index(:audit_entries, [:organization_id, "id DESC"])
create index(:audit_entries, [:organization_id, :category, "id DESC"])
create index(:audit_entries, [:repository_id, "id DESC"])
create index(:audit_entries, [:actor_id, "id DESC"])
create index(:audit_entries, [:subject_user_id, "id DESC"])
create index(:audit_entries, [:inserted_at])
end
end
neiam
/gitgud
Git Gud
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
1
Log in to mark this repository.
1.6 KiB · text
History
8ccf537