Class: BazaMigrations::Migrate

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

Instance Method Summary collapse

Instance Method Details

#execute_all_migrations(direction) ⇒ Object



14
15
16
# File 'lib/baza_migrations/migrate.rb', line 14

def execute_all_migrations(direction)
  migrations.execute_migrations(direction)
end

#migrationsObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/baza_migrations/migrate.rb', line 2

def migrations
  executor = BazaMigrations::MigrationsExecutor.new(db: Baza.default_db)

  paths.each do |path|
    migrations_path = "#{path}/db/baza_migrate"
    next unless File.exist?(migrations_path)
    executor.add_dir(migrations_path)
  end

  executor
end

#pathsObject



18
19
20
21
22
23
24
25
26
# File 'lib/baza_migrations/migrate.rb', line 18

def paths
  Enumerator.new do |yielder|
    yielder << Dir.pwd

    Gem.loaded_specs.each do |_name, loaded_spec|
      yielder << loaded_spec.gem_dir
    end
  end
end