class Miteru::Database

Public Class Methods

close() click to toggle source
# File lib/miteru/database.rb, line 58
def close
  ActiveRecord::Base.clear_active_connections!
  ActiveRecord::Base.connection.close
end
connect() click to toggle source
# File lib/miteru/database.rb, line 38
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)
  V11Schema.migrate(:up)
rescue StandardError => _e
  # Do nothing
end
destroy!() click to toggle source
# File lib/miteru/database.rb, line 63
def destroy!
  return unless ActiveRecord::Base.connected?

  InitialSchema.migrate(:down)
  V11Schema.migrate(:down)
end