Sha256: 1b2c77dee09d484ad2171617a99a8adb4a98fcffab370ee01f6cfdf71f65e154

Contents?: true

Size: 708 Bytes

Versions: 2

Compression:

Stored size: 708 Bytes

Contents

module Ryakuzu
  class MigrationService
    attr_accessor :columns, :table, :old_table

    def initialize(params = {})
      @columns   = params['column']
      @table     = params['name']
      @old_table = params['old_name']
    end

    def call
      run_table_migration(old_table, table) if table != old_table

      columns.each_slice(2) do |k, v|
        run_column_migration(v[1], k[1], table) if k[1] != v[1]
      end
    end

    private

    def run_table_migration(old_table, new_table)
      Ryakuzu::TableService.new(old_table, new_table).call
    end

    def run_column_migration(old_name, new_name, table)
      Ryakuzu::ColumnService.new(old_name, new_name, table).call
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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