Sha256: 8afa23fc068bbd4da56a62d9cd35b383cd47e0f5e3a09f519620b11bdf0ddbf6
Contents?: true
Size: 854 Bytes
Versions: 51
Compression:
Stored size: 854 Bytes
Contents
# frozen_string_literal: true require_relative 'base' module DeclareSchema module SchemaChange class IndexAdd < Base def initialize(table_name, column_names, name:, unique:, where: nil) @table_name = table_name @column_names = column_names @name = name @unique = unique @where = where.presence end def up_command options = { name: @name.to_sym, } options[:unique] = true if @unique options[:where] = @where if @where "add_index #{[@table_name.to_sym.inspect, @column_names.map(&:to_sym).inspect, *self.class.format_options(options)].join(', ')}" end def down_command "remove_index #{@table_name.to_sym.inspect}, name: #{@name.to_sym.inspect}" end end end end
Version data entries
51 entries across 51 versions & 1 rubygems