Skip to content

Commit

Permalink
Added test for different options
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Nov 7, 2024
1 parent d6878da commit 7d7eb96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/migrations/add_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ def change
end
end

class AddIndexUnique < TestMigration
def change
add_index :users, :name, unique: true
end
end

class AddIndexUp < TestMigration
def self.up
add_index :users, :name
Expand Down
5 changes: 5 additions & 0 deletions test/safe_by_default_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def test_add_index_invalid
end
end

# fail if same name but different options
assert_raises(ActiveRecord::StatementInvalid) do
migrate AddIndexUnique
end

migrate AddIndex

# fail if trying to add the same index in a future migration
Expand Down

0 comments on commit 7d7eb96

Please sign in to comment.