Class: AfterMigrate::Stores::FileStore

Inherits:
Memory
  • Object
show all
Defined in:
lib/after_migrate/store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, run_id: nil) ⇒ FileStore

Returns a new instance of FileStore.



30
31
32
33
34
# File 'lib/after_migrate/store.rb', line 30

def initialize(path:, run_id: nil)
  super()
  @path = path.to_s
  @run_id = run_id.to_s.presence
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



28
29
30
# File 'lib/after_migrate/store.rb', line 28

def path
  @path
end

#run_idObject (readonly)

Returns the value of attribute run_id.



28
29
30
# File 'lib/after_migrate/store.rb', line 28

def run_id
  @run_id
end

Instance Method Details

#affected_tablesObject



36
37
38
39
# File 'lib/after_migrate/store.rb', line 36

def affected_tables
  load_into_memory
  super
end

#merge_tables(schema, table_names) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/after_migrate/store.rb', line 41

def merge_tables(schema, table_names)
  return if table_names.blank?

  with_lock do
    merge_into_memory(read_schemas)
    merge_into_memory(schema => table_names)
    write_schemas(memory_to_hash)
  end
end

#reset!Object



51
52
53
54
# File 'lib/after_migrate/store.rb', line 51

def reset!
  super
  with_lock { ::FileUtils.rm_f(path) }
end