Moved db defonce to a db namespace function.