Sha256: 2f2d948c34dbe384f4d1de1363a03bc128a8e0c12d9734756ccb068e8fefaca0

Contents?: true

Size: 1.26 KB

Versions: 24

Compression:

Stored size: 1.26 KB

Contents

class AddSimpleGuardsOptionsToRules < ActiveRecord::Migration[5.1]
  def change
    add_column :gemini_my_rules, :simple_guards_options, :jsonb, null: false, default: {}
    add_column :gemini_xyz_rules, :simple_guards_options, :jsonb, null: false, default: {}

    reversible do |dir|
      dir.up { create_indexes }
    end
  end

  def create_indexes
    ['gemini_my_rules',  'g_array',    :array,
     'gemini_my_rules',  'g_single',   :scalar,
     'gemini_my_rules',  'g_string',   :scalar,
     'gemini_my_rules',  'g_bool',     :scalar,
     'gemini_my_rules',  'g_integer',  :scalar,
     'gemini_my_rules',  'g_range',    :range,
     'gemini_xyz_rules', 'flavors',    :array,
     'gemini_xyz_rules', 'guard_two',  :scalar,
     'gemini_xyz_rules', 'g_date',     :scalar,
     'gemini_xyz_rules', 'g_datetime', :scalar,
     'gemini_xyz_rules', 'g_bool',     :scalar,
     'gemini_xyz_rules', 'g_integer',  :scalar,
     'gemini_xyz_rules', 'g_range1',   :range,
     'gemini_xyz_rules', 'g_range2',   :range,
    ].in_groups_of(3).each do |table, field, type|

      col = "(simple_guards_options -> '#{field}' -> 'not')"
      sql = <<-SQL
        CREATE INDEX idx_#{table}_#{field}_not ON #{table} USING BTREE
        (#{col});
      SQL

      execute sql
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
marty-14.3.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-14.0.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-13.0.2 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-11.0.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-10.0.3 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-10.0.2 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-10.0.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-9.5.1 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-9.5.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-9.3.3 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-9.3.2 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-9.3.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-8.5.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-8.4.1 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-8.3.1 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-8.2.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-8.0.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-6.1.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-5.2.0 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb
marty-5.1.4 spec/dummy/db/migrate/20190702115241_add_simple_guards_options_to_rules.rb