[Groonga-commit] ranguba/groonga-client-model at c6219d4 [master] migration: support boolean

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Mar 6 11:25:44 JST 2017


Kouhei Sutou	2017-03-06 11:25:44 +0900 (Mon, 06 Mar 2017)

  New Revision: c6219d413ac178258f1746505b8ba65d9834262a
  https://github.com/ranguba/groonga-client-model/commit/c6219d413ac178258f1746505b8ba65d9834262a

  Message:
    migration: support boolean

  Modified files:
    lib/groonga_client_model/migration.rb
    test/unit/migration/test_create_table.rb

  Modified: lib/groonga_client_model/migration.rb (+5 -0)
===================================================================
--- lib/groonga_client_model/migration.rb    2017-03-06 11:25:01 +0900 (99a7c39)
+++ lib/groonga_client_model/migration.rb    2017-03-06 11:25:44 +0900 (a557157)
@@ -323,6 +323,11 @@ module GroongaClientModel
         @table_name = table_name
       end
 
+      def boolean(column_name, options={})
+        @migration.add_column(@table_name, column_name, :bool, options)
+      end
+      alias_method :bool, :boolean
+
       def short_text(column_name, options={})
         @migration.add_column(@table_name, column_name, :short_text, options)
       end

  Modified: test/unit/migration/test_create_table.rb (+28 -0)
===================================================================
--- test/unit/migration/test_create_table.rb    2017-03-06 11:25:01 +0900 (d1c9e47)
+++ test/unit/migration/test_create_table.rb    2017-03-06 11:25:44 +0900 (1983744)
@@ -132,6 +132,34 @@ table_create terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --nor
   end
 
   sub_test_case("columns") do
+    sub_test_case("#boolean") do
+      test("default") do
+        expected_up_report = <<-REPORT
+-- create_table(:posts, {:type=>"TABLE_NO_KEY"})
+   -> 0.0s
+-- add_column(:posts, :published, {:flags=>["COLUMN_SCALAR"], :value_type=>"Bool"})
+   -> 0.0s
+        REPORT
+        expected_down_report = <<-REPORT
+-- remove_table(:posts)
+   -> 0.0s
+        REPORT
+        expected_dump = <<-DUMP.chomp
+table_create posts TABLE_NO_KEY
+column_create posts published COLUMN_SCALAR Bool
+        DUMP
+        assert_migrate(expected_up_report,
+                       expected_down_report,
+                       expected_dump) do |migration|
+          migration.instance_eval do
+            create_table(:posts) do |table|
+              table.boolean(:published)
+            end
+          end
+        end
+      end
+    end
+
     sub_test_case("#short_text") do
       test("default") do
         expected_up_report = <<-REPORT
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index