Skip to content

Commit e059468

Browse files
authored
Page Scroll Goals: migration step 1 (#5033)
* migration: add scroll_threshold to goals * do not drop the old index yet
1 parent b4ec09c commit e059468

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
defmodule Plausible.Repo.Migrations.AddScrollThresholdToGoals do
2+
use Ecto.Migration
3+
4+
@disable_ddl_transaction true
5+
@disable_migration_lock true
6+
7+
@new_index unique_index(
8+
:goals,
9+
[:site_id, :page_path, :scroll_threshold],
10+
where: "page_path IS NOT NULL",
11+
name: :goals_page_path_and_scroll_threshold_unique
12+
)
13+
14+
def up do
15+
alter table(:goals) do
16+
add :scroll_threshold, :smallint, null: false, default: -1
17+
end
18+
19+
create(@new_index)
20+
end
21+
22+
def down do
23+
drop(@new_index)
24+
25+
alter table(:goals) do
26+
remove :scroll_threshold
27+
end
28+
end
29+
end

0 commit comments

Comments
 (0)