Sha256: f6f76e47b9482c1b9431d31955c5101e7240983f52bc2ef1c5e46981292d80b9

Contents?: true

Size: 454 Bytes

Versions: 2

Compression:

Stored size: 454 Bytes

Contents

module Ryakuzu
  class AddColumnService
    attr_reader :table, :column, :type

    def initialize(table, column, type)
      @table  = table
      @column = column
      @type   = type
    end

    def call
      text = text_migration
      Ryakuzu::RunMigration.new(new_column: column).call(table, text, 'table')
    end

    private

    def text_migration
      "add_column :#{table.tableize}, :#{column}, :#{type.downcase.to_sym}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ryakuzu-0.3.0 lib/ryakuzu/services/add_column_service.rb
ryakuzu-0.2.6 app/services/ryakuzu/add_column_service.rb