class Squasher::Cleaner
Constants
- MIGRATION_NAME
Public Class Methods
process(*args)
click to toggle source
# File lib/squasher/cleaner.rb, line 7 def self.process(*args) new(*args).process end
Public Instance Methods
process()
click to toggle source
# 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
Private Instance Methods
config()
click to toggle source
# File lib/squasher/cleaner.rb, line 26 def config Squasher.config end
now_timestamp()
click to toggle source
# File lib/squasher/cleaner.rb, line 38 def now_timestamp Time.now.strftime("%Y%m%d%H%M%S") end
prev_migration()
click to toggle source
# File lib/squasher/cleaner.rb, line 30 def prev_migration return @prev_migration if defined?(@prev_migration) @prev_migration = config.migration_files.detect do |file| File.basename(file).include?(MIGRATION_NAME) end end