Sha256: fd02adc402a4fdf2d3b7647bcf9d546b69195372851d20abae23469f21dbaaf4

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

# Copyright (c) 2011 - 2013, SoundCloud Ltd., Rany Keddo, Tobias Bielohlawek, Tobias
# Schmidt

require 'lhm/intersection'
require 'lhm/timestamp'

module Lhm
  class Migration
    attr_reader :origin, :destination, :renames

    def initialize(origin, destination, conditions = nil, renames = {}, time = Time.now)
      @origin = origin
      @destination = destination
      @conditions = conditions
      @renames = renames
      @table_name = TableName.new(@origin.name, time)
    end

    def conditions
      if @conditions.kind_of?(Proc)
        @conditions.call
      else
        @conditions
      end
    end

    def archive_name
      @archive_name ||= @table_name.archived
    end

    def intersection
      Intersection.new(@origin, @destination, @renames)
    end

    def origin_name
      @table_name.original
    end

    def origin_columns
      @origin_columns ||= intersection.origin.typed(origin_name)
    end

    def destination_name
      @destination_name ||= destination.name
    end

    def destination_columns
      @destination_columns ||= intersection.destination.joined
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lhm-teak-3.6.4 lib/lhm/migration.rb
lhm-teak-3.6.3 lib/lhm/migration.rb
lhm-teak-3.6.2 lib/lhm/migration.rb
lhm-teak-3.6.1 lib/lhm/migration.rb
lhm-teak-3.6.0 lib/lhm/migration.rb