Skip to content

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

Redo migration: Add scroll_depth to imported_pages (#4926)

RobertJoonas27422f0dd421
diff --git a/priv/ingest_repo/migrations/20241216133031_add_scroll_depth_to_imported_pages.exs b/priv/ingest_repo/migrations/20241216133031_add_scroll_depth_to_imported_pages.exs
index d3a50e5dd7..bac6c85f9e 100644
--- a/priv/ingest_repo/migrations/20241216133031_add_scroll_depth_to_imported_pages.exs
+++ b/priv/ingest_repo/migrations/20241216133031_add_scroll_depth_to_imported_pages.exs
@@ -15,7 +15,7 @@ defmodule Plausible.IngestRepo.Migrations.AddScrollDepthToImportedPages do
execute """
ALTER TABLE imported_pages
#{@on_cluster}
- DROP COLUMN scroll_depth
+ DROP COLUMN IF EXISTS scroll_depth
"""
end
end
diff --git a/priv/ingest_repo/migrations/20241218102326_drop_and_add_scroll_depth_to_imported_pages.exs b/priv/ingest_repo/migrations/20241218102326_drop_and_add_scroll_depth_to_imported_pages.exs
new file mode 100644
index 0000000000..49db290219
--- /dev/null
+++ b/priv/ingest_repo/migrations/20241218102326_drop_and_add_scroll_depth_to_imported_pages.exs
@@ -0,0 +1,27 @@
+defmodule Plausible.IngestRepo.Migrations.DropAndAddScrollDepthToImportedPages do
+ use Ecto.Migration
+
+ @on_cluster Plausible.MigrationUtils.on_cluster_statement("imported_pages")
+
+ def up do
+ execute """
+ ALTER TABLE imported_pages
+ #{@on_cluster}
+ DROP COLUMN scroll_depth
+ """
+
+ execute """
+ ALTER TABLE imported_pages
+ #{@on_cluster}
+ ADD COLUMN scroll_depth Nullable(UInt64)
+ """
+ end
+
+ def down do
+ execute """
+ ALTER TABLE imported_pages
+ #{@on_cluster}
+ DROP COLUMN scroll_depth
+ """
+ end
+end