Sha256: ba6c47d16af22ef36b5a009b79c156de6ee61357f405e0d80bd3bdabb2a6ca91

Contents?: true

Size: 999 Bytes

Versions: 70

Compression:

Stored size: 999 Bytes

Contents

# frozen_string_literal: true

require_relative 'base'

module DeclareSchema
  module SchemaChange
    class ColumnChange < Base
      def initialize(table_name, column_name, old_type:, old_options:, new_type:, new_options:)
        @table_name = table_name
        @column_name = column_name
        @old_type = old_type
        @old_options = old_options
        @new_type = new_type
        @new_options = new_options
      end

      def up_command
        "change_column #{[@table_name.to_sym.inspect,
                          @column_name.to_sym.inspect,
                          @new_type.to_sym.inspect,
                          *self.class.format_options(@new_options)].join(", ")}"
      end

      def down_command
        "change_column #{[@table_name.to_sym.inspect,
                          @column_name.to_sym.inspect,
                          @old_type.to_sym.inspect,
                          *self.class.format_options(@old_options)].join(", ")}"
      end
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
declare_schema-2.3.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-2.3.0 lib/declare_schema/schema_change/column_change.rb
declare_schema-2.3.0.pre.is.0 lib/declare_schema/schema_change/column_change.rb
declare_schema-2.2.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-2.2.0.colin.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-2.2.0 lib/declare_schema/schema_change/column_change.rb
declare_schema-2.1.0 lib/declare_schema/schema_change/column_change.rb
declare_schema-2.1.0.pre.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0.colin.11 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.6 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.6.colin.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.5 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.5.colin.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0.colin.9 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.4 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.4.colin.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0.colin.8 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.3 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.3.colin.1 lib/declare_schema/schema_change/column_change.rb