Kouhei Sutou
null+****@clear*****
Tue Aug 16 10:17:32 JST 2016
Kouhei Sutou 2016-08-16 10:17:32 +0900 (Tue, 16 Aug 2016) New Revision: a7049c0b47c8b86b1416c3ad05ab9d78ac30eee2 https://github.com/groonga/groonga-schema/commit/a7049c0b47c8b86b1416c3ad05ab9d78ac30eee2 Message: Create index after all columns are migrated Modified files: lib/groonga-schema/table.rb test/test-diff.rb Modified: lib/groonga-schema/table.rb (+10 -6) =================================================================== --- lib/groonga-schema/table.rb 2016-08-15 18:28:16 +0900 (9f76aab) +++ lib/groonga-schema/table.rb 2016-08-16 10:17:32 +0900 (894b460) @@ -81,12 +81,11 @@ module GroongaSchema else sorted_columns =****@colum*****_by(&:name) sorted_columns.each do |column| + next if column.type == :index new_column = Column.new(new_name, column.name) new_column.apply_column(column) commands << new_column.to_create_groonga_command - unless column.type == :index - commands << column.to_copy_groonga_command(new_name, column.name) - end + commands << column.to_copy_groonga_command(new_name, column.name) end end commands << table_rename_command(@name, old_name) @@ -95,9 +94,14 @@ module GroongaSchema end def to_migrate_finish_groonga_commands - [ - table_remove_command(old_name), - ] + commands = [] + sorted_columns =****@colum*****_by(&:name) + sorted_columns.each do |column| + next unless column.type == :index + commands << column.to_create_groonga_command + end + commands << table_remove_command(old_name) + commands end private Modified: test/test-diff.rb (+6 -6) =================================================================== --- test/test-diff.rb 2016-08-15 18:28:16 +0900 (d24ffbd) +++ test/test-diff.rb 2016-08-16 10:17:32 +0900 (72ce135) @@ -373,12 +373,6 @@ table_create \\ --normalizer "NormalizerAuto" \\ --token_filters "TokenFilterStopWord|TokenFilterStem" column_create \\ - --flags "COLUMN_INDEX|WITH_POSITION" \\ - --name "commands_description" \\ - --source "description" \\ - --table "Words_new" \\ - --type "Commands" -column_create \\ --flags "COLUMN_SCALAR" \\ --name "weight" \\ --table "Words_new" \\ @@ -429,6 +423,12 @@ table_rename \\ table_remove \\ --name "Names_old" +column_create \\ + --flags "COLUMN_INDEX|WITH_POSITION" \\ + --name "commands_description" \\ + --source "description" \\ + --table "Words" \\ + --type "Commands" table_remove \\ --name "Words_old" -------------- next part -------------- HTML����������������������������... Download