Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_reference support #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/Gemfile.lock
*.swp
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source :rubygems
source 'https://rubygems.org'
gemspec

case ENV['DB_NAZI_ADAPTER']
Expand Down
5 changes: 5 additions & 0 deletions lib/db_nazi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ def check_index(options)
raise IndexUniquenessRequired, "[db_nazi] :unique parameter required"
end
end

def check_reference(options)
check_index(options) and
self.require_index_uniqueness = false
end
end

reset
Expand Down
5 changes: 5 additions & 0 deletions lib/db_nazi/abstract_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def add_index(table_name, column_name, options = {})
super
end

def add_reference(table_name, ref_name, options = {})
DBNazi.check_reference(options)
super
end

def change_column(table_name, column_name, type, options = {})
DBNazi.check_column(type, options)
super
Expand Down