Add database resource only if @database is not nil