Skip to content

Commit

Permalink
Add :ignore option
Browse files Browse the repository at this point in the history
  • Loading branch information
winebarrel committed Jan 12, 2019
1 parent dfb1da4 commit 5f5d68e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ Apply `Schemafile`
...
```

## Running tests
## Run tests

```sh
docker-compose up -d
Expand Down
12 changes: 11 additions & 1 deletion lib/ridgepole/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ def scan_definition_change(from, to, from_indices, table_name, table_options, ta
end

to.each do |column_name, to_attrs|
if (from_attrs = from.delete(column_name))
ignore_column = to_attrs.fetch(:options, {}).delete(:ignore)
from_attrs = from.delete(column_name)
next if ignore_column

if from_attrs
to_attrs = build_attrs_if_changed(to_attrs, from_attrs, table_name)
if to_attrs
definition_delta[:change] ||= {}
Expand Down Expand Up @@ -296,6 +300,8 @@ def scan_indices_change(from, to, to_columns, table_delta, _from_table_options,
indices_delta = {}

to.each do |index_name, to_attrs|
ignore_index = to_attrs.fetch(:options, {}).delete(:ignore)

if index_name.is_a?(Array)
from_index_name, from_attrs = from.find { |_name, attrs| attrs[:column_name] == index_name }

Expand All @@ -307,6 +313,8 @@ def scan_indices_change(from, to, to_columns, table_delta, _from_table_options,
from_attrs = from.delete(index_name)
end

next if ignore_index

if from_attrs
normalize_index_options!(from_attrs[:options])
normalize_index_options!(to_attrs[:options])
Expand Down Expand Up @@ -391,7 +399,9 @@ def scan_foreign_keys_change(from, to, table_delta, options)
foreign_keys_delta = {}

to.each do |foreign_key_name_or_tables, to_attrs|
ignore_fk = to_attrs.fetch(:options, {}).delete(:ignore)
from_attrs = from.delete(foreign_key_name_or_tables)
next if ignore_fk

if from_attrs
if from_attrs != to_attrs
Expand Down

0 comments on commit 5f5d68e

Please sign in to comment.