Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Migration: audit entries (#5581)

Adam Rutkowskica2611fc83cc
diff --git a/priv/repo/migrations/20250708102205_audit_entries.exs b/priv/repo/migrations/20250708102205_audit_entries.exs
new file mode 100644
index 0000000000..0f5259bf89
--- /dev/null
+++ b/priv/repo/migrations/20250708102205_audit_entries.exs
@@ -0,0 +1,28 @@
+defmodule Plausible.Repo.Migrations.AuditEntries do
+ use Ecto.Migration
+
+ import Plausible.MigrationUtils
+
+ def change do
+ if enterprise_edition?() do
+ create table(:audit_entries, primary_key: false) do
+ add(:id, :uuid, primary_key: true)
+ add :name, :string, null: false
+ add :entity, :string, null: false
+ add :entity_id, :string, null: false
+ add :meta, :map, default: %{}
+ add :change, :map, default: %{}
+ add :user_id, :integer
+ add :team_id, :integer
+ add :datetime, :naive_datetime_usec, null: false
+ add :actor_type, :string, null: false
+ end
+
+ create index(:audit_entries, [:entity])
+ create index(:audit_entries, [:entity_id])
+ create index(:audit_entries, [:user_id])
+ create index(:audit_entries, [:team_id])
+ create index(:audit_entries, [:datetime])
+ end
+ end
+end