Sha256: ec66cfda5986dde99544b614cc69ca7b097621043b0346ae8b369e85a86142e8

Contents?: true

Size: 526 Bytes

Versions: 2

Compression:

Stored size: 526 Bytes

Contents

module Ryakuzu
  class ColumnService
    attr_accessor :old_column, :new_column, :table

    def initialize(old_column, new_column, table)
      @old_column = old_column
      @new_column = new_column
      @table      = table
    end

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

    private

    def text_migration
      "rename_column :#{table.tableize}, :#{old_column}, :#{new_column}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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