Skip to content

Commit a8cda3c

Browse files
committed
Merge with migration step 3 (PR #5036)
2 parents 1896791 + 537d22a commit a8cda3c

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

priv/repo/migrations/20250128161815_add_scroll_threshold_to_goals.exs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ defmodule Plausible.Repo.Migrations.AddScrollThresholdToGoals do
44
@disable_ddl_transaction true
55
@disable_migration_lock true
66

7-
# Plausible.Repo.Migrations.GoalsUnique
8-
@old_index unique_index(
9-
:goals,
10-
[:site_id, :page_path],
11-
where: "page_path IS NOT NULL",
12-
name: :goals_page_path_unique
13-
)
14-
157
@new_index unique_index(
168
:goals,
179
[:site_id, :page_path, :scroll_threshold],
@@ -24,13 +16,11 @@ defmodule Plausible.Repo.Migrations.AddScrollThresholdToGoals do
2416
add :scroll_threshold, :smallint, null: false, default: -1
2517
end
2618

27-
drop(@old_index)
2819
create(@new_index)
2920
end
3021

3122
def down do
3223
drop(@new_index)
33-
create(@old_index)
3424

3525
alter table(:goals) do
3626
remove :scroll_threshold
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
defmodule Plausible.Repo.Migrations.DropUniquePagePathConstraintFromGoals do
2+
use Ecto.Migration
3+
4+
@disable_ddl_transaction true
5+
@disable_migration_lock true
6+
7+
# Plausible.Repo.Migrations.GoalsUnique
8+
@old_index unique_index(
9+
:goals,
10+
[:site_id, :page_path],
11+
where: "page_path IS NOT NULL",
12+
name: :goals_page_path_unique
13+
)
14+
15+
def up do
16+
drop(@old_index)
17+
end
18+
19+
def down do
20+
create(@old_index)
21+
end
22+
end

test/plausible/goals_test.exs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ defmodule Plausible.GoalsTest do
9999
assert {:error, changeset} =
100100
Goals.create(site, %{"page_path" => "foo bar", "display_name" => "two"})
101101

102-
assert {"has already been taken", _} =
103-
changeset.errors[:page_path]
102+
assert {"has already been taken", _} = changeset.errors[:page_path]
104103
end
105104

106105
test "create/2 fails to create the same custom event goal twice" do

0 commit comments

Comments
 (0)