Class: Tern

Inherits:
Object
  • Object
show all
Defined in:
lib/tern.rb

Instance Method Summary collapse

Constructor Details

#initialize(alterations_table, alterations_column, definitions_table) ⇒ Tern

Returns a new instance of Tern.



180
181
182
183
184
185
186
187
188
189
190
# File 'lib/tern.rb', line 180

def initialize(alterations_table, alterations_column, definitions_table)
  Alteration.table_name = alterations_table.to_sym
  Alteration.version_column = alterations_column.to_sym
  Alteration.ensure_table_exists
  @alterations = Alteration.load 'alterations'

  Definition.table_name = definitions_table.to_sym
  Definition.ensure_table_exists
  @existing_definitions = Definition.load_existing
  @target_definitions = Definition.load_targets 'definitions/sequence.yml'
end

Instance Method Details

#migrate(options = {}) ⇒ Object



192
193
194
195
196
197
198
199
# File 'lib/tern.rb', line 192

def migrate(options={})
  sequences = options[:sequences] || ['default']
  DB.transaction do
    drop_existing_definitions(sequences)
    run_alterations(options[:version])
    create_target_definitions(sequences)
  end
end