Class: Nandi::CompileGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/nandi/compile/compile_generator.rb

Instance Method Summary collapse

Instance Method Details

#compile_migration_filesObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/generators/nandi/compile/compile_generator.rb', line 30

def compile_migration_files
  databases.each do |db_name|
    Nandi.compile(files: files(db_name), db_name: db_name) do |results|
      results.each do |result|
        Nandi::Lockfile.for(db_name).add(
          file_name: result.file_name,
          source_digest: result.source_digest,
          compiled_digest: result.compiled_digest,
        )
        unless result.migration_unchanged?
          create_file result.output_path, result.body, force: true
        end
      end
    end
    Nandi::Lockfile.for(db_name).persist!
  end
end