Class: Squasher::Cleaner

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

Constant Summary collapse

MIGRATION_NAME =
'squasher_clean'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.process(*args) ⇒ Object



7
8
9
# File 'lib/squasher/cleaner.rb', line 7

def self.process(*args)
  new(*args).process
end

Instance Method Details

#processObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/squasher/cleaner.rb', line 11

def process
  Squasher.error(:migration_folder_missing) unless config.migrations_folder?

  migration_file = config.migration_file(now_timestamp, MIGRATION_NAME)
  if prev_migration
    FileUtils.rm(prev_migration)
  end
  File.open(migration_file, 'wb') do |stream|
    stream << ::Squasher::Render.render(MIGRATION_NAME, config)
  end
  Squasher.rake("db:migrate", :db_cleaning)
end