Skip to content

Commit

Permalink
Merge with migration step 3 (PR #5036)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertJoonas committed Feb 3, 2025
2 parents 1896791 + 537d22a commit a8cda3c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ defmodule Plausible.Repo.Migrations.AddScrollThresholdToGoals do
@disable_ddl_transaction true
@disable_migration_lock true

# Plausible.Repo.Migrations.GoalsUnique
@old_index unique_index(
:goals,
[:site_id, :page_path],
where: "page_path IS NOT NULL",
name: :goals_page_path_unique
)

@new_index unique_index(
:goals,
[:site_id, :page_path, :scroll_threshold],
Expand All @@ -24,13 +16,11 @@ defmodule Plausible.Repo.Migrations.AddScrollThresholdToGoals do
add :scroll_threshold, :smallint, null: false, default: -1
end

drop(@old_index)
create(@new_index)
end

def down do
drop(@new_index)
create(@old_index)

alter table(:goals) do
remove :scroll_threshold
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
defmodule Plausible.Repo.Migrations.DropUniquePagePathConstraintFromGoals do
use Ecto.Migration

@disable_ddl_transaction true
@disable_migration_lock true

# Plausible.Repo.Migrations.GoalsUnique
@old_index unique_index(
:goals,
[:site_id, :page_path],
where: "page_path IS NOT NULL",
name: :goals_page_path_unique
)

def up do
drop(@old_index)
end

def down do
create(@old_index)
end
end
3 changes: 1 addition & 2 deletions test/plausible/goals_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ defmodule Plausible.GoalsTest do
assert {:error, changeset} =
Goals.create(site, %{"page_path" => "foo bar", "display_name" => "two"})

assert {"has already been taken", _} =
changeset.errors[:page_path]
assert {"has already been taken", _} = changeset.errors[:page_path]
end

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

0 comments on commit a8cda3c

Please sign in to comment.