Class: Miteru::Database
- Inherits:
-
Object
- Object
- Miteru::Database
- Defined in:
- lib/miteru/database.rb
Class Method Summary collapse
Class Method Details
.close ⇒ Object
51 52 53 54 |
# File 'lib/miteru/database.rb', line 51 def close ActiveRecord::Base.clear_active_connections! ActiveRecord::Base.connection.close end |
.connect ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/miteru/database.rb', line 32 def connect case adapter when "postgresql", "mysql2" ActiveRecord::Base.establish_connection(Miteru.configuration.database) else ActiveRecord::Base.establish_connection( adapter: adapter, database: Miteru.configuration.database ) end # ActiveRecord::Base.logger = Logger.new STDOUT ActiveRecord::Migration.verbose = false InitialSchema.migrate(:up) rescue StandardError => _e # Do nothing end |
.destroy! ⇒ Object
56 57 58 59 60 |
# File 'lib/miteru/database.rb', line 56 def destroy! return unless ActiveRecord::Base.connected? InitialSchema.migrate(:down) end |