Skip to content

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

migration to add createCustomEventArray function (#5085)

Karl-Aksel Puulmann3ccc7b906b9e
diff --git a/priv/ingest_repo/migrations/20250218094453_create_custom_event_array_function.exs b/priv/ingest_repo/migrations/20250218094453_create_custom_event_array_function.exs
new file mode 100644
index 0000000000..01155568f2
--- /dev/null
+++ b/priv/ingest_repo/migrations/20250218094453_create_custom_event_array_function.exs
@@ -0,0 +1,15 @@
+defmodule Plausible.IngestRepo.Migrations.CreateCustomEventArrayFunction do
+ use Ecto.Migration
+
+ def up do
+ execute """
+ CREATE OR REPLACE FUNCTION createCustomEventArray
+ #{Plausible.MigrationUtils.on_cluster_statement("events_v2")}
+ AS (foundIndex, scaleBy) -> (if(foundIndex > 0, [toUInt64(foundIndex + scaleBy)], []));
+ """
+ end
+
+ def down do
+ raise "irreversible"
+ end
+end