Sha256: 9b9fda35ce856965e8f43986c03c9f1929dd96602d7b005fb2596d911c74d8c9
Contents?: true
Size: 706 Bytes
Versions: 6
Compression:
Stored size: 706 Bytes
Contents
module DummyApp module Migrations extend self # Ensure database exists def database_exists? ActiveRecord::Base.connection rescue ActiveRecord::NoDatabaseError false else true end def needs_migration? !database_exists? || ActiveRecord::Migrator.needs_migration? end def auto_migrate if needs_migration? puts "Configuration changed. Re-running migrations" sh 'rake db:reset VERBOSE=false' # We might have a brand new database, so we must re-establish our connection ActiveRecord::Base.establish_connection end end private def sh(cmd) puts cmd system cmd end end end
Version data entries
6 entries across 6 versions & 1 rubygems