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-1.4.0.colin.7 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0.colin.6 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0.colin.5 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0.colin.4 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0.colin.3 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0.colin.2 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.4.0.colin.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.2 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.2.rp.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.1.colin.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.0 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.3.0.colin.1 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.2.3 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.2.3.pre.ga.11 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.2.3.pre.ga.10 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.2.3.pre.ga.9 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.2.3.pre.ga.8 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.2.3.pre.ga.7 lib/declare_schema/schema_change/column_change.rb
declare_schema-1.2.3.pre.ga.6 lib/declare_schema/schema_change/column_change.rb